summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorvmallika <vmallika@redhat.com>2015-07-12 21:03:54 +0530
committerRaghavendra G <rgowdapp@redhat.com>2015-07-14 02:59:50 -0700
commite73db5e7fe1dba5a071725ef3480a4a1d5c7bef7 (patch)
tree84196f42075c910277099c15cf1580b53a22e469 /xlators
parentd51ddfe8f8839ccb419eb2d8a7cf024d3f5fdeeb (diff)
quota/marker: fix mem-leak in marker
Free local in error paths Change-Id: I76f69e7d746af8eedea34354ff5a6bf50234e50e BUG: 1207735 Signed-off-by: vmallika <vmallika@redhat.com> Reviewed-on: http://review.gluster.org/11617 Tested-by: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/features/marker/src/marker.c81
-rw-r--r--xlators/features/marker/src/marker.h12
2 files changed, 44 insertions, 49 deletions
diff --git a/xlators/features/marker/src/marker.c b/xlators/features/marker/src/marker.c
index 4494595cc39..e8a8eeab6e4 100644
--- a/xlators/features/marker/src/marker.c
+++ b/xlators/features/marker/src/marker.c
@@ -338,10 +338,6 @@ marker_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, dict_t *dict,
dict_t *xdata)
{
- marker_local_t *local = NULL;
- local = frame->local;
-
-
if (cookie) {
gf_log (this->name, GF_LOG_DEBUG,
"Filtering the quota extended attributes");
@@ -367,9 +363,7 @@ marker_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
marker_filter_internal_xattrs (frame->this, dict);
}
- frame->local = NULL;
- STACK_UNWIND_STRICT (getxattr, frame, op_ret, op_errno, dict, xdata);
- marker_local_unref (local);
+ MARKER_STACK_UNWIND (getxattr, frame, op_ret, op_errno, dict, xdata);
return 0;
}
@@ -417,9 +411,7 @@ marker_getxattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
return 0;
out:
- frame->local = NULL;
- STACK_UNWIND_STRICT (getxattr, frame, -1, ENOMEM, NULL, NULL);
- marker_local_unref (local);
+ MARKER_STACK_UNWIND (getxattr, frame, -1, ENOMEM, NULL, NULL);
return 0;
}
@@ -656,8 +648,9 @@ wind:
return 0;
err:
- STACK_UNWIND_STRICT (mkdir, frame, -1, ENOMEM, NULL,
+ MARKER_STACK_UNWIND (mkdir, frame, -1, ENOMEM, NULL,
NULL, NULL, NULL, NULL);
+
return 0;
}
@@ -730,7 +723,7 @@ wind:
fd, xdata);
return 0;
err:
- STACK_UNWIND_STRICT (create, frame, -1, ENOMEM, NULL, NULL, NULL, NULL,
+ MARKER_STACK_UNWIND (create, frame, -1, ENOMEM, NULL, NULL, NULL, NULL,
NULL, NULL);
return 0;
@@ -806,7 +799,7 @@ wind:
flags, iobref, xdata);
return 0;
err:
- STACK_UNWIND_STRICT (writev, frame, -1, ENOMEM, NULL, NULL, NULL);
+ MARKER_STACK_UNWIND (writev, frame, -1, ENOMEM, NULL, NULL, NULL);
return 0;
}
@@ -874,7 +867,7 @@ wind:
FIRST_CHILD(this)->fops->rmdir, loc, flags, xdata);
return 0;
err:
- STACK_UNWIND_STRICT (rmdir, frame, -1, ENOMEM, NULL, NULL, NULL);
+ MARKER_STACK_UNWIND (rmdir, frame, -1, ENOMEM, NULL, NULL, NULL);
return 0;
}
@@ -953,9 +946,7 @@ unlink_wind:
FIRST_CHILD(this)->fops->unlink, loc, xflag, xdata);
return 0;
err:
- frame->local = NULL;
- STACK_UNWIND_STRICT (unlink, frame, -1, ENOMEM, NULL, NULL, NULL);
- marker_local_unref (local);
+ MARKER_STACK_UNWIND (unlink, frame, -1, ENOMEM, NULL, NULL, NULL);
return 0;
}
@@ -1029,7 +1020,7 @@ wind:
FIRST_CHILD(this)->fops->link, oldloc, newloc, xdata);
return 0;
err:
- STACK_UNWIND_STRICT (link, frame, -1, ENOMEM, NULL, NULL, NULL, NULL,
+ MARKER_STACK_UNWIND (link, frame, -1, ENOMEM, NULL, NULL, NULL, NULL,
NULL);
return 0;
@@ -1611,8 +1602,9 @@ rename_wind:
return 0;
err:
- STACK_UNWIND_STRICT (rename, frame, -1, ENOMEM, NULL,
+ MARKER_STACK_UNWIND (rename, frame, -1, ENOMEM, NULL,
NULL, NULL, NULL, NULL, NULL);
+ marker_local_unref (oplocal);
return 0;
}
@@ -1681,7 +1673,7 @@ wind:
FIRST_CHILD(this)->fops->truncate, loc, offset, xdata);
return 0;
err:
- STACK_UNWIND_STRICT (truncate, frame, -1, ENOMEM, NULL, NULL, NULL);
+ MARKER_STACK_UNWIND (truncate, frame, -1, ENOMEM, NULL, NULL, NULL);
return 0;
}
@@ -1749,7 +1741,7 @@ wind:
FIRST_CHILD(this)->fops->ftruncate, fd, offset, xdata);
return 0;
err:
- STACK_UNWIND_STRICT (ftruncate, frame, -1, ENOMEM, NULL, NULL, NULL);
+ MARKER_STACK_UNWIND (ftruncate, frame, -1, ENOMEM, NULL, NULL, NULL);
return 0;
}
@@ -1823,8 +1815,9 @@ wind:
xdata);
return 0;
err:
- STACK_UNWIND_STRICT (symlink, frame, -1, ENOMEM, NULL,
+ MARKER_STACK_UNWIND (symlink, frame, -1, ENOMEM, NULL,
NULL, NULL, NULL, NULL);
+
return 0;
}
@@ -1899,8 +1892,9 @@ wind:
xdata);
return 0;
err:
- STACK_UNWIND_STRICT (mknod, frame, -1, ENOMEM, NULL,
+ MARKER_STACK_UNWIND (mknod, frame, -1, ENOMEM, NULL,
NULL, NULL, NULL, NULL);
+
return 0;
}
@@ -1968,7 +1962,7 @@ wind:
xdata);
return 0;
err:
- STACK_UNWIND_STRICT (fallocate, frame, -1, ENOMEM, NULL, NULL, NULL);
+ MARKER_STACK_UNWIND (fallocate, frame, -1, ENOMEM, NULL, NULL, NULL);
return 0;
}
@@ -2036,7 +2030,7 @@ wind:
FIRST_CHILD(this)->fops->discard, fd, offset, len, xdata);
return 0;
err:
- STACK_UNWIND_STRICT (discard, frame, -1, ENOMEM, NULL, NULL, NULL);
+ MARKER_STACK_UNWIND (discard, frame, -1, ENOMEM, NULL, NULL, NULL);
return 0;
}
@@ -2103,7 +2097,7 @@ wind:
FIRST_CHILD(this)->fops->zerofill, fd, offset, len, xdata);
return 0;
err:
- STACK_UNWIND_STRICT (zerofill, frame, -1, ENOMEM, NULL, NULL, NULL);
+ MARKER_STACK_UNWIND (zerofill, frame, -1, ENOMEM, NULL, NULL, NULL);
return 0;
}
@@ -2224,16 +2218,11 @@ quota_xattr_cleaner_cbk (int ret, call_frame_t *frame, void *args)
dict_t *xdata = args;
int op_ret = -1;
int op_errno = 0;
- marker_local_t *local = NULL;
-
- local = frame->local;
- frame->local = NULL;
op_ret = (ret < 0)? -1: 0;
op_errno = -ret;
- STACK_UNWIND_STRICT (setxattr, frame, op_ret, op_errno, xdata);
- marker_local_unref (local);
+ MARKER_STACK_UNWIND (setxattr, frame, op_ret, op_errno, xdata);
return ret;
}
@@ -2307,11 +2296,9 @@ marker_do_xattr_cleanup (call_frame_t *frame, xlator_t *this, dict_t *xdata,
ret = 0;
out:
- if (ret) {
- frame->local = NULL;
- STACK_UNWIND_STRICT (setxattr, frame, -1, ENOMEM, xdata);
- marker_local_unref (local);
- }
+ if (ret)
+ MARKER_STACK_UNWIND (setxattr, frame, -1, ENOMEM, xdata);
+
return ret;
}
@@ -2366,7 +2353,7 @@ wind:
FIRST_CHILD(this)->fops->setxattr, loc, dict, flags, xdata);
return 0;
err:
- STACK_UNWIND_STRICT (setxattr, frame, -1, op_errno, NULL);
+ MARKER_STACK_UNWIND (setxattr, frame, -1, op_errno, NULL);
return 0;
}
@@ -2433,7 +2420,7 @@ wind:
FIRST_CHILD(this)->fops->fsetxattr, fd, dict, flags, xdata);
return 0;
err:
- STACK_UNWIND_STRICT (fsetxattr, frame, -1, ENOMEM, NULL);
+ MARKER_STACK_UNWIND (fsetxattr, frame, -1, ENOMEM, NULL);
return 0;
}
@@ -2499,7 +2486,7 @@ wind:
FIRST_CHILD (this)->fops->fsetattr, fd, stbuf, valid, xdata);
return 0;
err:
- STACK_UNWIND_STRICT (fsetattr, frame, -1, ENOMEM, NULL, NULL, NULL);
+ MARKER_STACK_UNWIND (fsetattr, frame, -1, ENOMEM, NULL, NULL, NULL);
return 0;
}
@@ -2566,7 +2553,7 @@ wind:
FIRST_CHILD (this)->fops->setattr, loc, stbuf, valid, xdata);
return 0;
err:
- STACK_UNWIND_STRICT (setattr, frame, -1, ENOMEM, NULL, NULL, NULL);
+ MARKER_STACK_UNWIND (setattr, frame, -1, ENOMEM, NULL, NULL, NULL);
return 0;
}
@@ -2631,7 +2618,7 @@ wind:
FIRST_CHILD(this)->fops->removexattr, loc, name, xdata);
return 0;
err:
- STACK_UNWIND_STRICT (removexattr, frame, -1, ENOMEM, NULL);
+ MARKER_STACK_UNWIND (removexattr, frame, -1, ENOMEM, NULL);
return 0;
}
@@ -2741,7 +2728,7 @@ wind:
return 0;
err:
- STACK_UNWIND_STRICT (lookup, frame, -1, ENOMEM, NULL, NULL, NULL, NULL);
+ MARKER_STACK_UNWIND (lookup, frame, -1, ENOMEM, NULL, NULL, NULL, NULL);
if (xattr_req)
dict_unref (xattr_req);
@@ -2853,11 +2840,7 @@ marker_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
unwind:
- local = frame->local;
- frame->local = NULL;
-
- STACK_UNWIND_STRICT (readdirp, frame, op_ret, op_errno, entries, xdata);
- marker_local_unref (local);
+ MARKER_STACK_UNWIND (readdirp, frame, op_ret, op_errno, entries, xdata);
return 0;
}
@@ -2901,7 +2884,7 @@ marker_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
dict_unref (dict);
return 0;
unwind:
- STACK_UNWIND_STRICT (readdirp, frame, -1, ENOMEM, NULL, NULL);
+ MARKER_STACK_UNWIND (readdirp, frame, -1, ENOMEM, NULL, NULL);
return 0;
}
diff --git a/xlators/features/marker/src/marker.h b/xlators/features/marker/src/marker.h
index 0f98ac960a3..6e43e74d5a6 100644
--- a/xlators/features/marker/src/marker.h
+++ b/xlators/features/marker/src/marker.h
@@ -75,6 +75,18 @@ enum {
frame->cookie = NULL; \
} while (0)
+#define MARKER_STACK_UNWIND(fop, frame, params...) \
+ do { \
+ quota_local_t *_local = NULL; \
+ if (frame) { \
+ _local = frame->local; \
+ frame->local = NULL; \
+ } \
+ STACK_UNWIND_STRICT (fop, frame, params); \
+ if (_local) \
+ marker_local_unref (_local); \
+ } while (0)
+
struct marker_local{
uint32_t timebuf[2];
pid_t pid;