diff options
author | Amar Tumballi <amar@gluster.com> | 2010-07-02 04:55:28 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2010-07-02 05:17:03 -0700 |
commit | 2f15ffd6b5beef9abd501c594bc3cb38c2683f77 (patch) | |
tree | 107176560e1a97c42f3535380ef49d4dee3b0cd6 /xlators/protocol/client/src/client3_1-fops.c | |
parent | 3dc79ca8e6119f5ff61058cc87f9a4fc251017ef (diff) |
NULL dereference fixes in code base after running with 'clang'
* 212 logical (NULL deref/divide by zero) errors reduced to 28
(27 of them in contrib/ and lex part of codebase, 1 is invalid)
* 11 API errors reduced to 0
Signed-off-by: Amar Tumballi <amar@gluster.com>
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
BUG: 966 (NULL check for avoiding NULL dereferencing of pointers..)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=966
Diffstat (limited to 'xlators/protocol/client/src/client3_1-fops.c')
-rw-r--r-- | xlators/protocol/client/src/client3_1-fops.c | 49 |
1 files changed, 34 insertions, 15 deletions
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); |