From 2f15ffd6b5beef9abd501c594bc3cb38c2683f77 Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Fri, 2 Jul 2010 04:55:28 +0000 Subject: 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 Signed-off-by: Anand V. Avati BUG: 966 (NULL check for avoiding NULL dereferencing of pointers..) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=966 --- xlators/protocol/client/src/client3_1-fops.c | 49 +++++++++++++++++++--------- 1 file changed, 34 insertions(+), 15 deletions(-) (limited to 'xlators/protocol/client/src/client3_1-fops.c') diff --git a/xlators/protocol/client/src/client3_1-fops.c b/xlators/protocol/client/src/client3_1-fops.c index f91eebad..5204ef03 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); -- cgit