diff options
30 files changed, 193 insertions, 123 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index 694a9040c..1be1f8126 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -150,7 +150,8 @@ gf_resolve_ip6 (const char *hostname, *addr_info = cache->next; } - cache->next = cache->next->ai_next; + if (cache->next) + cache->next = cache->next->ai_next; if (cache->next) { ret = getnameinfo((struct sockaddr *)cache->next->ai_addr, cache->next->ai_addrlen, diff --git a/libglusterfs/src/dict.c b/libglusterfs/src/dict.c index 7d560bdac..ca6275f26 100644 --- a/libglusterfs/src/dict.c +++ b/libglusterfs/src/dict.c @@ -581,9 +581,10 @@ dict_unserialize_old (char *buf, int32_t size, dict_t **fill) int32_t ret = 0; int32_t cnt = 0; - if (!buf || fill == NULL || !*fill) { + if (!buf || !fill || !(*fill)) { gf_log ("dict", GF_LOG_ERROR, - "@buf=%p @fill=%p @*fill=%p", buf, fill, *fill); + "@buf=%p @fill=%p @*fill=%p", + buf, fill, (fill) ? (*fill) : NULL); return NULL; } diff --git a/libglusterfs/src/event.c b/libglusterfs/src/event.c index 819357d43..7ac891fa1 100644 --- a/libglusterfs/src/event.c +++ b/libglusterfs/src/event.c @@ -867,7 +867,7 @@ event_dispatch_epoll (struct event_pool *event_pool) size = ret; for (i = 0; i < size; i++) { - if (!events[i].events) + if (!events || !events[i].events) continue; ret = event_dispatch_epoll_handler (event_pool, diff --git a/libglusterfs/src/graph.l b/libglusterfs/src/graph.l index 8d9d2dc36..f7a02e481 100644 --- a/libglusterfs/src/graph.l +++ b/libglusterfs/src/graph.l @@ -45,12 +45,14 @@ void append_string(const char *str, int size) } else { text = GF_REALLOC (text, new_size); } - if (!text) + if (!text) { gf_log ("parser", GF_LOG_ERROR, "out of memory"); + return; + } text_asize = new_size; } - memcpy(text + text_size, str, size); + memcpy(text + text_size, str, size); text_size += size; text[text_size] = 0; } diff --git a/libglusterfs/src/graph.y b/libglusterfs/src/graph.y index 4ac07660f..14afaae64 100644 --- a/libglusterfs/src/graph.y +++ b/libglusterfs/src/graph.y @@ -382,7 +382,7 @@ yyerror (const char *str) extern char *yytext; extern int yylineno; - if (curr && curr->name) { + if (curr && curr->name && yytext) { if (!strcmp (yytext, "volume")) { gf_log ("parser", GF_LOG_ERROR, "'end-volume' not defined for volume '%s'", diff --git a/libglusterfs/src/stack.h b/libglusterfs/src/stack.h index ac69e389f..1ce46ccdc 100644 --- a/libglusterfs/src/stack.h +++ b/libglusterfs/src/stack.h @@ -253,7 +253,10 @@ STACK_DESTROY (call_stack_t *stack) ret_fn_t fn = NULL; \ call_frame_t *_parent = NULL; \ xlator_t *old_THIS = NULL; \ - \ + if (!frame) { \ + gf_log ("stack", GF_LOG_CRITICAL, "!frame"); \ + break; \ + } \ fn = frame->ret; \ _parent = frame->parent; \ _parent->ref_count--; \ @@ -277,6 +280,10 @@ STACK_DESTROY (call_stack_t *stack) call_frame_t *_parent = NULL; \ xlator_t *old_THIS = NULL; \ \ + if (!frame) { \ + gf_log ("stack", GF_LOG_CRITICAL, "!frame"); \ + break; \ + } \ fn = (fop_##op##_cbk_t )frame->ret; \ _parent = frame->parent; \ _parent->ref_count--; \ diff --git a/rpc/rpc-lib/src/rpcsvc-auth.c b/rpc/rpc-lib/src/rpcsvc-auth.c index fa039c386..75305e68e 100644 --- a/rpc/rpc-lib/src/rpcsvc-auth.c +++ b/rpc/rpc-lib/src/rpcsvc-auth.c @@ -200,8 +200,10 @@ __rpcsvc_auth_get_handler (rpcsvc_request_t *req) return NULL; svc = rpcsvc_request_service (req); - if (!svc) - gf_log ("", 1, "something wrong, !svc"); + if (!svc) { + gf_log (GF_RPCSVC, GF_LOG_ERROR, "!svc"); + goto err; + } if (list_empty (&svc->authschemes)) { gf_log (GF_RPCSVC, GF_LOG_WARNING, "No authentication!"); diff --git a/xlators/cluster/afr/src/afr-inode-read.c b/xlators/cluster/afr/src/afr-inode-read.c index b1bbac10b..ef72fb197 100644 --- a/xlators/cluster/afr/src/afr-inode-read.c +++ b/xlators/cluster/afr/src/afr-inode-read.c @@ -802,7 +802,7 @@ afr_readv_cbk (call_frame_t *frame, void *cookie, out: if (unwind) { - if (buf) + if (buf && local) buf->ia_ino = local->cont.readv.ino; AFR_STACK_UNWIND (readv, frame, op_ret, op_errno, diff --git a/xlators/cluster/afr/src/afr.c b/xlators/cluster/afr/src/afr.c index 718384717..4ae128bbb 100644 --- a/xlators/cluster/afr/src/afr.c +++ b/xlators/cluster/afr/src/afr.c @@ -2744,7 +2744,7 @@ init (xlator_t *this) int32_t background_count = 0; int32_t lock_server_count = 1; - int32_t window_size; + int32_t window_size = 0; int fav_ret = -1; int read_ret = -1; @@ -2780,8 +2780,8 @@ init (xlator_t *this) &background_count); if (dict_ret == 0) { gf_log (this->name, GF_LOG_DEBUG, - "Setting background self-heal count to %d.", - window_size); + "Setting background self-heal count to %d", + background_count); priv->background_self_heal_count = background_count; } @@ -2819,7 +2819,7 @@ init (xlator_t *this) &window_size); if (dict_ret == 0) { gf_log (this->name, GF_LOG_DEBUG, - "Setting data self-heal window size to %d.", + "Setting data self-heal window size to %d", window_size); priv->data_self_heal_window_size = window_size; diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h index b223a9de3..4580bcda2 100644 --- a/xlators/cluster/afr/src/afr.h +++ b/xlators/cluster/afr/src/afr.h @@ -558,15 +558,15 @@ typedef struct { /* try alloc and if it fails, goto label */ -#define ALLOC_OR_GOTO(var, type, label) do { \ - var = GF_CALLOC (sizeof (type), 1, \ - gf_afr_mt_##type); \ - if (!var) { \ - gf_log (this->name, GF_LOG_ERROR, \ - "out of memory :("); \ - op_errno = ENOMEM; \ - goto label; \ - } \ +#define ALLOC_OR_GOTO(var, type, label) do { \ + var = GF_CALLOC (sizeof (type), 1, \ + gf_afr_mt_##type); \ + if (!var) { \ + gf_log (this->name, GF_LOG_ERROR, \ + "out of memory :("); \ + op_errno = ENOMEM; \ + goto label; \ + } \ } while (0); @@ -639,13 +639,15 @@ afr_cleanup_fd_ctx (xlator_t *this, fd_t *fd); do { \ afr_local_t *__local = NULL; \ xlator_t *__this = NULL; \ - __local = frame->local; \ - __this = frame->this; \ - frame->local = NULL; \ + if (frame) { \ + __local = frame->local; \ + __this = frame->this; \ + frame->local = NULL; \ + } \ STACK_UNWIND_STRICT (fop, frame, params); \ - afr_local_cleanup (__local, __this); \ + afr_local_cleanup (__local, __this); \ GF_FREE (__local); \ -} while (0); + } while (0); #define AFR_STACK_DESTROY(frame) \ do { \ @@ -657,7 +659,7 @@ afr_cleanup_fd_ctx (xlator_t *this, fd_t *fd); STACK_DESTROY (frame->root); \ afr_local_cleanup (__local, __this); \ GF_FREE (__local); \ -} while (0); + } while (0); /* allocate and return a string that is the basename of argument */ static inline char * diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h index b51f308ec..b361f1442 100644 --- a/xlators/cluster/dht/src/dht-common.h +++ b/xlators/cluster/dht/src/dht-common.h @@ -183,9 +183,11 @@ typedef struct dht_disk_layout dht_disk_layout_t; #define DHT_STACK_UNWIND(fop, frame, params ...) do { \ dht_local_t *__local = NULL; \ xlator_t *__xl = NULL; \ - __xl = frame->this; \ - __local = frame->local; \ - frame->local = NULL; \ + if (frame) { \ + __xl = frame->this; \ + __local = frame->local; \ + frame->local = NULL; \ + } \ STACK_UNWIND_STRICT (fop, frame, params); \ dht_local_wipe (__xl, __local); \ } while (0) diff --git a/xlators/cluster/dht/src/dht-rename.c b/xlators/cluster/dht/src/dht-rename.c index d96c4b8a3..d88fc7445 100644 --- a/xlators/cluster/dht/src/dht-rename.c +++ b/xlators/cluster/dht/src/dht-rename.c @@ -260,6 +260,12 @@ dht_rename_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, local = frame->local; prev = cookie; + if (!local) { + gf_log (this->name, GF_LOG_ERROR, + "!local, should not happen"); + goto out; + } + this_call_cnt = dht_frame_return (frame); if (op_ret == -1) { @@ -273,12 +279,14 @@ dht_rename_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, WIPE (&local->preparent); WIPE (&local->postparent); - if (is_last_call (this_call_cnt)) + if (is_last_call (this_call_cnt)) { DHT_STACK_UNWIND (rename, frame, local->op_ret, local->op_errno, &local->stbuf, &local->preoldparent, &local->postoldparent, &local->preparent, &local->postparent); + } +out: return 0; } diff --git a/xlators/cluster/dht/src/dht-selfheal.c b/xlators/cluster/dht/src/dht-selfheal.c index 8cfb1f41f..9270952e1 100644 --- a/xlators/cluster/dht/src/dht-selfheal.c +++ b/xlators/cluster/dht/src/dht-selfheal.c @@ -336,7 +336,7 @@ dht_selfheal_layout_new_directory (call_frame_t *frame, loc_t *loc, } } - chunk = ((unsigned long) 0xffffffff) / cnt; + chunk = ((unsigned long) 0xffffffff) / ((cnt) ? cnt : 1); start_subvol = dht_selfheal_layout_alloc_start (this, loc, layout); diff --git a/xlators/cluster/stripe/src/stripe.c b/xlators/cluster/stripe/src/stripe.c index 99346fac2..4826d80a8 100644 --- a/xlators/cluster/stripe/src/stripe.c +++ b/xlators/cluster/stripe/src/stripe.c @@ -3284,7 +3284,6 @@ stripe_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, call_frame_t *rframe = NULL; stripe_local_t *rlocal = NULL; xlator_list_t *trav = NULL; - stripe_private_t *priv = NULL; stripe_fd_ctx_t *fctx = NULL; VALIDATE_OR_GOTO (frame, err); @@ -3293,7 +3292,6 @@ stripe_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, VALIDATE_OR_GOTO (fd->inode, err); trav = this->children; - priv = this->private; fd_ctx_get (fd, this, &tmp_fctx); if (!tmp_fctx) { @@ -3303,6 +3301,11 @@ stripe_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, fctx = (stripe_fd_ctx_t *)(long)tmp_fctx; stripe_size = fctx->stripe_size; + if (!stripe_size) { + gf_log (this->name, GF_LOG_DEBUG, + "Wrong stripe size for the file"); + goto err; + } /* The file is stripe across the child nodes. Send the read request * to the child nodes appropriately after checking which region of * the file is in which child node. Always '0-<stripe_size>' part of @@ -3310,7 +3313,7 @@ stripe_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, */ rounded_start = floor (offset, stripe_size); rounded_end = roof (offset+size, stripe_size); - num_stripe = rounded_end/stripe_size - rounded_start/stripe_size; + num_stripe = (rounded_end- rounded_start)/stripe_size; local = GF_CALLOC (1, sizeof (stripe_local_t), gf_stripe_mt_stripe_local_t); @@ -3361,7 +3364,7 @@ stripe_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, return 0; err: - if (local->fd) + if (local && local->fd) fd_unref (local->fd); STACK_UNWIND_STRICT (readv, frame, -1, op_errno, NULL, 0, NULL, NULL); diff --git a/xlators/features/trash/src/trash.c b/xlators/features/trash/src/trash.c index c51d55a02..d60bf4b83 100644 --- a/xlators/features/trash/src/trash.c +++ b/xlators/features/trash/src/trash.c @@ -96,7 +96,8 @@ trash_unlink_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, local = frame->local; tmp_str = gf_strdup (local->newpath); if (!tmp_str) { - gf_log (this->name, GF_LOG_DEBUG, "out of memory"); + gf_log (this->name, GF_LOG_ERROR, "out of memory"); + goto out; } loop_count = local->loop_count; @@ -113,7 +114,8 @@ trash_unlink_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, } tmp_path = memdup (local->newpath, count); if (!tmp_path) { - gf_log (this->name, GF_LOG_DEBUG, "out of memory"); + gf_log (this->name, GF_LOG_ERROR, "out of memory"); + goto out; } tmp_loc.path = tmp_path; @@ -156,7 +158,8 @@ trash_unlink_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, } tmp_path = memdup (local->newpath, count); if (!tmp_path) { - gf_log (this->name, GF_LOG_DEBUG, "out of memory"); + gf_log (this->name, GF_LOG_ERROR, "out of memory"); + goto out; } tmp_loc.path = tmp_path; @@ -167,7 +170,8 @@ trash_unlink_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, out: GF_FREE (cookie); - GF_FREE (tmp_str); + if (tmp_str) + GF_FREE (tmp_str); return 0; } @@ -399,6 +403,7 @@ trash_rename_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, tmp_str = gf_strdup (local->newpath); if (!tmp_str) { gf_log (this->name, GF_LOG_DEBUG, "out of memory"); + goto out; } if ((op_ret == -1) && (op_errno == ENOENT)) { @@ -439,7 +444,8 @@ trash_rename_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, out: GF_FREE (cookie); /* strdup (dir_name) was sent here :) */ - GF_FREE (tmp_str); + if (tmp_str) + GF_FREE (tmp_str); return 0; } @@ -848,13 +854,14 @@ trash_truncate_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, local = frame->local; if (!local) - return 0; + goto out; loop_count = local->loop_count; tmp_str = gf_strdup (local->newpath); if (!tmp_str) { gf_log (this->name, GF_LOG_DEBUG, "out of memory"); + goto out; } if ((op_ret == -1) && (op_errno == ENOENT)) { @@ -902,6 +909,7 @@ trash_truncate_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, loop_count = ++local->loop_count; } UNLOCK (&frame->lock); + tmp_dirname = strchr (tmp_str, '/'); while (tmp_dirname) { count = tmp_dirname - tmp_str; @@ -926,7 +934,8 @@ trash_truncate_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, out: GF_FREE (cookie); /* strdup (dir_name) was sent here :) */ - GF_FREE (tmp_str); + if (tmp_str) + GF_FREE (tmp_str); return 0; } @@ -1213,13 +1222,14 @@ trash_ftruncate_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, local = frame->local; if (!local) - return 0; + goto out; loop_count = local->loop_count; tmp_str = gf_strdup (local->newpath); if (!tmp_str) { gf_log (this->name, GF_LOG_DEBUG, "out of memory"); + goto out; } if ((op_ret == -1) && (op_errno == ENOENT)) { @@ -1292,7 +1302,8 @@ trash_ftruncate_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, out: GF_FREE (cookie); /* strdup (dir_name) was sent here :) */ - GF_FREE (tmp_str); + if (tmp_str) + GF_FREE (tmp_str); return 0; } @@ -1484,6 +1495,7 @@ init (xlator_t *this) gf_trash_mt_trash_elim_pattern_t); if (!trav) { gf_log (this->name, GF_LOG_DEBUG, "out of memory"); + break; } trav->pattern = component; trav->next = _priv->eliminate; diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c index 483c6c9fe..096ca93df 100644 --- a/xlators/mount/fuse/src/fuse-bridge.c +++ b/xlators/mount/fuse/src/fuse-bridge.c @@ -1364,9 +1364,8 @@ fuse_readlink (xlator_t *this, fuse_in_header_t *finh, void *msg) if ((state->loc.inode == NULL) || (ret < 0)) { gf_log ("glusterfs-fuse", GF_LOG_WARNING, - "%"PRIu64" READLINK %s/%"PRId64" (fuse_loc_fill() returned NULL inode)", - finh->unique, state->loc.path, - state->loc.inode->ino); + "%"PRIu64" READLINK %s (fuse_loc_fill() returned NULL inode)", + finh->unique, state->loc.path); send_fuse_err (this, finh, ENOENT); free_state (state); return; @@ -3719,9 +3718,9 @@ cleanup_exit: if (priv) { GF_FREE (priv->mount_point); close (priv->fd); + close (priv->fuse_dump_fd); + GF_FREE (priv); } - GF_FREE (priv); - close (priv->fuse_dump_fd); return -1; } diff --git a/xlators/nfs/server/src/nfs3-helpers.c b/xlators/nfs/server/src/nfs3-helpers.c index 95e860162..615c21660 100644 --- a/xlators/nfs/server/src/nfs3-helpers.c +++ b/xlators/nfs/server/src/nfs3-helpers.c @@ -394,12 +394,12 @@ nfs3_fill_lookup3res_success (lookup3res *res, nfsstat3 stat, obj.attributes_follow = FALSE; dir.attributes_follow = FALSE; - if (buf) { + if (buf && fh) { nfs3_map_xlid_to_statdev (buf, fh->xlatorid); obj = nfs3_stat_to_post_op_attr (buf); } - if (postparent) { + if (postparent && fh) { nfs3_map_xlid_to_statdev (postparent, fh->xlatorid); dir = nfs3_stat_to_post_op_attr (postparent); } diff --git a/xlators/performance/stat-prefetch/src/stat-prefetch.c b/xlators/performance/stat-prefetch/src/stat-prefetch.c index b34aba58c..fb338491e 100644 --- a/xlators/performance/stat-prefetch/src/stat-prefetch.c +++ b/xlators/performance/stat-prefetch/src/stat-prefetch.c @@ -573,6 +573,7 @@ sp_fd_ctx_new (xlator_t *this, inode_t *parent, char *name, sp_cache_t *cache) if (fd_ctx->name == NULL) { sp_fd_ctx_free (fd_ctx); fd_ctx = NULL; + goto out; } } @@ -1099,8 +1100,8 @@ wind: } unwind: - SP_STACK_UNWIND (lookup, frame, op_ret, op_errno, loc->inode, &buf, - NULL, &postparent); + SP_STACK_UNWIND (lookup, frame, op_ret, op_errno, (loc)?loc->inode:NULL, + &buf, NULL, &postparent); return 0; } diff --git a/xlators/performance/write-behind/src/write-behind.c b/xlators/performance/write-behind/src/write-behind.c index a71d3a378..4095527d8 100644 --- a/xlators/performance/write-behind/src/write-behind.c +++ b/xlators/performance/write-behind/src/write-behind.c @@ -252,11 +252,11 @@ wb_enqueue (wb_file_t *file, call_stub_t *stub) vector = stub->args.writev.vector; count = stub->args.writev.count; - frame = stub->frame; - local = frame->local; request->write_size = iov_length (vector, count); - local->op_ret = request->write_size; - local->op_errno = 0; + if (local) { + local->op_ret = request->write_size; + local->op_errno = 0; + } request->flags.write_request.virgin = 1; } diff --git a/xlators/protocol/client/src/client-handshake.c b/xlators/protocol/client/src/client-handshake.c index 58d23779c..1c239d0cb 100644 --- a/xlators/protocol/client/src/client-handshake.c +++ b/xlators/protocol/client/src/client-handshake.c @@ -520,7 +520,7 @@ client_setvolume (xlator_t *this, struct rpc_clnt *rpc) options = this->options; conf = this->private; - if (conf->fops || !dict_get (options, "fops-version")) { + if (conf->fops) { ret = dict_set_int32 (options, "fops-version", conf->fops->prognum); if (ret < 0) { diff --git a/xlators/protocol/client/src/client3_1-fops.c b/xlators/protocol/client/src/client3_1-fops.c index f91eebadd..5204ef032 100644 --- a/xlators/protocol/client/src/client3_1-fops.c +++ b/xlators/protocol/client/src/client3_1-fops.c @@ -280,7 +280,6 @@ client3_1_mkdir_cbk (struct rpc_req *req, struct iovec *iov, int count, } out: - frame->local = NULL; STACK_UNWIND_STRICT (mkdir, frame, rsp.op_ret, gf_error_to_errno (rsp.op_errno), inode, &stbuf, &preparent, &postparent); @@ -2115,9 +2114,11 @@ client_fdctx_destroy (xlator_t *this, clnt_fd_ctx_t *fdctx) } out: - fdctx->remote_fd = -1; - inode_unref (fdctx->inode); - GF_FREE (fdctx); + if (fdctx) { + fdctx->remote_fd = -1; + inode_unref (fdctx->inode); + GF_FREE (fdctx); + } return ret; } @@ -2237,8 +2238,10 @@ out: if (fdctx) client_fdctx_destroy (frame->this, fdctx); - frame->local = NULL; - STACK_DESTROY (frame->root); + if (frame) { + frame->local = NULL; + STACK_DESTROY (frame->root); + } client_local_wipe (local); @@ -2555,15 +2558,16 @@ client3_1_lookup (call_frame_t *frame, xlator_t *this, return 0; unwind: - frame->local = NULL; + if (frame) + frame->local = NULL; + STACK_UNWIND_STRICT (lookup, frame, -1, op_errno, NULL, NULL, NULL, NULL); if (local) client_local_wipe (local); - if (req.dict.dict_val) { + if (req.dict.dict_val) GF_FREE (req.dict.dict_val); - } return 0; } @@ -2900,8 +2904,11 @@ client3_1_symlink (call_frame_t *frame, xlator_t *this, return 0; unwind: - frame->local = NULL; + if (frame) + frame->local = NULL; + STACK_UNWIND_STRICT (symlink, frame, -1, op_errno, NULL, NULL, NULL, NULL); + if (local) client_local_wipe (local); return 0; @@ -3074,8 +3081,11 @@ client3_1_mknod (call_frame_t *frame, xlator_t *this, return 0; unwind: - frame->local = NULL; + if (frame) + frame->local = NULL; + STACK_UNWIND_STRICT (mknod, frame, -1, op_errno, NULL, NULL, NULL, NULL); + if (local) client_local_wipe (local); return 0; @@ -3130,8 +3140,11 @@ client3_1_mkdir (call_frame_t *frame, xlator_t *this, return 0; unwind: - frame->local = NULL; + if (frame) + frame->local = NULL; + STACK_UNWIND_STRICT (mkdir, frame, -1, op_errno, NULL, NULL, NULL, NULL); + if (local) client_local_wipe (local); return 0; @@ -3187,7 +3200,9 @@ client3_1_create (call_frame_t *frame, xlator_t *this, return 0; unwind: - frame->local = NULL; + if (frame) + frame->local = NULL; + STACK_UNWIND_STRICT (create, frame, -1, op_errno, NULL, NULL, NULL, NULL, NULL); if (local) client_local_wipe (local); @@ -3243,8 +3258,11 @@ client3_1_open (call_frame_t *frame, xlator_t *this, return 0; unwind: - frame->local = NULL; + if (frame) + frame->local = NULL; + STACK_UNWIND_STRICT (open, frame, -1, op_errno, NULL); + if (local) client_local_wipe (local); return 0; @@ -3555,7 +3573,8 @@ client3_1_opendir (call_frame_t *frame, xlator_t *this, return 0; unwind: - frame->local = NULL; + if (frame) + frame->local = NULL; STACK_UNWIND_STRICT (opendir, frame, -1, op_errno, NULL); if (local) client_local_wipe (local); diff --git a/xlators/protocol/legacy/client/src/client-protocol.c b/xlators/protocol/legacy/client/src/client-protocol.c index dae31dcb3..0dc5bee5d 100644 --- a/xlators/protocol/legacy/client/src/client-protocol.c +++ b/xlators/protocol/legacy/client/src/client-protocol.c @@ -302,6 +302,8 @@ call_bail (void *data) gf_ops = gf_cbks; gf_op_list = gf_cbk_list; break; + default: + goto out; } localtime_r (&trav->saved_at.tv_sec, &frame_sent_tm); @@ -3255,6 +3257,9 @@ client_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, client_local_t *local = NULL; char *buf = NULL; + GF_VALIDATE_OR_GOTO (this->name, loc, unwind); + GF_VALIDATE_OR_GOTO (this->name, loc->path, unwind); + local = GF_CALLOC (1, sizeof (*local), gf_client_mt_client_local_t); GF_VALIDATE_OR_GOTO (this->name, local, unwind); @@ -3262,9 +3267,6 @@ client_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, frame->local = local; - GF_VALIDATE_OR_GOTO (this->name, loc, unwind); - GF_VALIDATE_OR_GOTO (this->name, loc->path, unwind); - if (loc->ino != 1 && loc->parent) { ret = inode_ctx_get2 (loc->parent, this, &par, &gen); if (loc->parent->ino && ret < 0) { @@ -3319,7 +3321,7 @@ client_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, return ret; unwind: - STACK_UNWIND (frame, op_ret, op_errno, loc->inode, NULL, NULL); + STACK_UNWIND (frame, op_ret, op_errno, (loc)?loc->inode:NULL, NULL, NULL); return ret; } diff --git a/xlators/protocol/legacy/server/src/server-helpers.c b/xlators/protocol/legacy/server/src/server-helpers.c index 7ab2ce885..595916a36 100644 --- a/xlators/protocol/legacy/server/src/server-helpers.c +++ b/xlators/protocol/legacy/server/src/server-helpers.c @@ -427,15 +427,17 @@ server_connection_destroy (xlator_t *this, server_connection_t *conn) INIT_LIST_HEAD (&file_lockers); INIT_LIST_HEAD (&dir_lockers); - LOCK (<able->lock); - { - list_splice_init (<able->file_lockers, - &file_lockers); + if (ltable) { + LOCK (<able->lock); + { + list_splice_init (<able->file_lockers, + &file_lockers); - list_splice_init (<able->dir_lockers, &dir_lockers); + list_splice_init (<able->dir_lockers, &dir_lockers); + } + UNLOCK (<able->lock); + GF_FREE (ltable); } - UNLOCK (<able->lock); - GF_FREE (ltable); flock.l_type = F_UNLCK; flock.l_start = 0; diff --git a/xlators/protocol/legacy/server/src/server-protocol.c b/xlators/protocol/legacy/server/src/server-protocol.c index 6a48dff39..da0303019 100644 --- a/xlators/protocol/legacy/server/src/server-protocol.c +++ b/xlators/protocol/legacy/server/src/server-protocol.c @@ -147,7 +147,7 @@ server_print_params (char *str, int size, server_state_t *state) "wbflags=%d,", state->wbflags); if (state->size) filled += snprintf (str + filled, size - filled, - "size=%Zu,", state->size); + "size=%zu,", state->size); if (state->offset) filled += snprintf (str + filled, size - filled, "offset=%"PRId64",", state->offset); @@ -667,8 +667,8 @@ server_fentrylk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, gf_errno = gf_errno_to_error (op_errno); hdr->rsp.op_errno = hton32 (gf_errno); + state = CALL_STATE(frame); if (op_ret >= 0) { - state = CALL_STATE(frame); if (state->cmd == ENTRYLK_UNLOCK) gf_del_locker (conn->ltable, state->volume, NULL, state->fd, frame->root->pid); @@ -5656,7 +5656,7 @@ mop_setvolume (call_frame_t *frame, xlator_t *bound_xl, fail: dict_len = dict_serialized_length (reply); if (dict_len < 0) { - gf_log (xl->name, GF_LOG_DEBUG, + gf_log ("server", GF_LOG_DEBUG, "failed to get serialized length of reply dict"); op_ret = -1; op_errno = EINVAL; @@ -5670,7 +5670,7 @@ fail: if (dict_len) { ret = dict_serialize (reply, rsp->buf); if (ret < 0) { - gf_log (xl->name, GF_LOG_DEBUG, + gf_log ("server", GF_LOG_DEBUG, "failed to serialize reply dict"); op_ret = -1; op_errno = -ret; @@ -6524,15 +6524,19 @@ int notify (xlator_t *this, int32_t event, void *data, ...) { int ret = 0; - transport_t *trans = data; + transport_t *trans = NULL; peer_info_t *peerinfo = NULL; peer_info_t *myinfo = NULL; - if (trans != NULL) { - peerinfo = &(trans->peerinfo); - myinfo = &(trans->myinfo); + trans = data; + if (!trans) { + gf_log (this->name, GF_LOG_ERROR, "!trans"); + goto out; } + peerinfo = &(trans->peerinfo); + myinfo = &(trans->myinfo); + switch (event) { case GF_EVENT_POLLIN: ret = protocol_server_pollin (this, trans); @@ -6576,7 +6580,7 @@ notify (xlator_t *this, int32_t event, void *data, ...) default_notify (this, event, data); break; } - +out: return ret; } diff --git a/xlators/protocol/legacy/transport/ib-verbs/src/ib-verbs.c b/xlators/protocol/legacy/transport/ib-verbs/src/ib-verbs.c index 6714d32e7..85228bf4e 100644 --- a/xlators/protocol/legacy/transport/ib-verbs/src/ib-verbs.c +++ b/xlators/protocol/legacy/transport/ib-verbs/src/ib-verbs.c @@ -1718,8 +1718,8 @@ ib_verbs_init (transport_t *this) if (!priv->device) { gf_log ("transport/ib-verbs", GF_LOG_ERROR, - "could not create ib_verbs device for %s", - priv->device->device_name); + "could not create ib_verbs device for %s", + options->device_name); ret = -1; goto cleanup; } diff --git a/xlators/protocol/server/src/server-handshake.c b/xlators/protocol/server/src/server-handshake.c index bc4d4afa2..94586d20c 100644 --- a/xlators/protocol/server/src/server-handshake.c +++ b/xlators/protocol/server/src/server-handshake.c @@ -614,7 +614,7 @@ server_setvolume (rpcsvc_request_t *req) fail: rsp.dict.dict_len = dict_serialized_length (reply); if (rsp.dict.dict_len < 0) { - gf_log (this->name, GF_LOG_DEBUG, + gf_log ("server-handshake", GF_LOG_DEBUG, "failed to get serialized length of reply dict"); op_ret = -1; op_errno = EINVAL; @@ -627,7 +627,7 @@ fail: if (rsp.dict.dict_val) { ret = dict_serialize (reply, rsp.dict.dict_val); if (ret < 0) { - gf_log (this->name, GF_LOG_DEBUG, + gf_log ("server-handshake", GF_LOG_DEBUG, "failed to serialize reply dict"); op_ret = -1; op_errno = -ret; diff --git a/xlators/protocol/server/src/server-helpers.c b/xlators/protocol/server/src/server-helpers.c index 11c489e88..216204a8b 100644 --- a/xlators/protocol/server/src/server-helpers.c +++ b/xlators/protocol/server/src/server-helpers.c @@ -541,15 +541,17 @@ server_connection_destroy (xlator_t *this, server_connection_t *conn) INIT_LIST_HEAD (&file_lockers); INIT_LIST_HEAD (&dir_lockers); - LOCK (<able->lock); - { - list_splice_init (<able->file_lockers, - &file_lockers); + if (ltable) { + LOCK (<able->lock); + { + list_splice_init (<able->file_lockers, + &file_lockers); - list_splice_init (<able->dir_lockers, &dir_lockers); + list_splice_init (<able->dir_lockers, &dir_lockers); + } + UNLOCK (<able->lock); + GF_FREE (ltable); } - UNLOCK (<able->lock); - GF_FREE (ltable); flock.l_type = F_UNLCK; flock.l_start = 0; @@ -1030,7 +1032,7 @@ server_print_params (char *str, int size, server_state_t *state) "wbflags=%d,", state->wbflags); if (state->size) filled += snprintf (str + filled, size - filled, - "size=%Zu,", state->size); + "size=%zu,", state->size); if (state->offset) filled += snprintf (str + filled, size - filled, "offset=%"PRId64",", state->offset); diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c index 104274edd..a7501babb 100644 --- a/xlators/protocol/server/src/server.c +++ b/xlators/protocol/server/src/server.c @@ -593,10 +593,9 @@ init (xlator_t *this) ret = 0; out: - if (ret) + if (ret && this) this->fini (this); - return ret; } diff --git a/xlators/protocol/server/src/server3_1-fops.c b/xlators/protocol/server/src/server3_1-fops.c index 686c0350d..c04861ddf 100644 --- a/xlators/protocol/server/src/server3_1-fops.c +++ b/xlators/protocol/server/src/server3_1-fops.c @@ -4737,7 +4737,7 @@ server_lookup (rpcsvc_request_t *req) if (buf == NULL) { gf_log (conn->bound_xl->name, GF_LOG_ERROR, "out of memory"); - goto err; + goto out; } ret = dict_unserialize (buf, args.dict.dict_len, @@ -4748,7 +4748,7 @@ server_lookup (rpcsvc_request_t *req) "unserialize req-buffer to dictionary", frame->root->unique, state->resolve.path, state->resolve.ino); - goto err; + goto out; } state->dict = xattr_req; @@ -4761,7 +4761,7 @@ server_lookup (rpcsvc_request_t *req) resolve_and_resume (frame, server_lookup_resume); return 0; -err: +out: if (xattr_req) dict_unref (xattr_req); @@ -4771,7 +4771,7 @@ err: server_lookup_cbk (frame, NULL, frame->this, -1, EINVAL, NULL, NULL, NULL, NULL); - +err: return 0; } diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index e9a8fc886..2aba365e6 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -530,7 +530,7 @@ out: dict_ref (xattr); STACK_UNWIND_STRICT (lookup, frame, op_ret, op_errno, - loc->inode, &buf, xattr, &postparent); + (loc)?loc->inode:NULL, &buf, xattr, &postparent); if (xattr) dict_unref (xattr); @@ -1175,7 +1175,7 @@ posix_mknod (call_frame_t *frame, xlator_t *this, SET_TO_OLD_FS_ID (); STACK_UNWIND_STRICT (mknod, frame, op_ret, op_errno, - loc->inode, &stbuf, &preparent, &postparent); + (loc)?loc->inode:NULL, &stbuf, &preparent, &postparent); if ((op_ret == -1) && (!was_present)) { unlink (real_path); @@ -1430,7 +1430,7 @@ posix_mkdir (call_frame_t *frame, xlator_t *this, SET_TO_OLD_FS_ID (); STACK_UNWIND_STRICT (mkdir, frame, op_ret, op_errno, - loc->inode, &stbuf, &preparent, &postparent); + (loc)?loc->inode:NULL, &stbuf, &preparent, &postparent); if ((op_ret == -1) && (!was_present)) { unlink (real_path); @@ -1702,7 +1702,7 @@ posix_symlink (call_frame_t *frame, xlator_t *this, SET_TO_OLD_FS_ID (); STACK_UNWIND_STRICT (symlink, frame, op_ret, op_errno, - loc->inode, &stbuf, &preparent, &postparent); + (loc)?loc->inode:NULL, &stbuf, &preparent, &postparent); if ((op_ret == -1) && (!was_present)) { unlink (real_path); @@ -1925,7 +1925,8 @@ posix_link (call_frame_t *frame, xlator_t *this, SET_TO_OLD_FS_ID (); STACK_UNWIND_STRICT (link, frame, op_ret, op_errno, - oldloc->inode, &stbuf, &preparent, &postparent); + (oldloc)?oldloc->inode:NULL, &stbuf, &preparent, + &postparent); if ((op_ret == -1) && (!was_present)) { unlink (real_newpath); @@ -2145,7 +2146,8 @@ posix_create (call_frame_t *frame, xlator_t *this, } STACK_UNWIND_STRICT (create, frame, op_ret, op_errno, - fd, loc->inode, &stbuf, &preparent, &postparent); + fd, (loc)?loc->inode:NULL, &stbuf, &preparent, + &postparent); return 0; } @@ -3543,11 +3545,11 @@ do_xattrop (call_frame_t *frame, xlator_t *this, if (loc) { path = gf_strdup (loc->path); inode = loc->inode; - } else { + } else if (fd) { inode = fd->inode; } - while (trav) { + while (trav && inode) { count = trav->value->len / sizeof (int32_t); array = GF_CALLOC (count, sizeof (int32_t), gf_posix_mt_int32_t); |