summaryrefslogtreecommitdiffstats
path: root/xlators/protocol/client
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2010-07-02 04:55:28 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-07-02 05:17:03 -0700
commit2f15ffd6b5beef9abd501c594bc3cb38c2683f77 (patch)
tree107176560e1a97c42f3535380ef49d4dee3b0cd6 /xlators/protocol/client
parent3dc79ca8e6119f5ff61058cc87f9a4fc251017ef (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')
-rw-r--r--xlators/protocol/client/src/client-handshake.c2
-rw-r--r--xlators/protocol/client/src/client3_1-fops.c49
2 files changed, 35 insertions, 16 deletions
diff --git a/xlators/protocol/client/src/client-handshake.c b/xlators/protocol/client/src/client-handshake.c
index 58d23779cc1..1c239d0cb0f 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 f91eebaddc6..5204ef032da 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);