summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/stripe
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/cluster/stripe
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/cluster/stripe')
-rw-r--r--xlators/cluster/stripe/src/stripe.c11
1 files changed, 7 insertions, 4 deletions
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);