summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2011-10-02 11:34:41 +0530
committerVijay Bellur <vijay@gluster.com>2011-10-20 00:20:57 -0700
commit26a51e5e6ec1639a7601c0fc373fd9f6493b014a (patch)
treedd61dfa4519f95cbd439f5770ca99d9321ff0241 /libglusterfs/src
parent429550b75d2b97f24a102cc648bf9d8240965f93 (diff)
libglusterfs/syncop: fix minor memory leaks
* most of the leaks can happen in syncop_lookup(), if rsp_dict is not provided by user Change-Id: I5a887c45f1a46a91502147e44f7ed9d41f50dbc6 BUG: 3715 Reviewed-on: http://review.gluster.com/550 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@gluster.com>
Diffstat (limited to 'libglusterfs/src')
-rw-r--r--libglusterfs/src/syncop.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/libglusterfs/src/syncop.c b/libglusterfs/src/syncop.c
index a9b49bb58..9565048fe 100644
--- a/libglusterfs/src/syncop.c
+++ b/libglusterfs/src/syncop.c
@@ -325,10 +325,12 @@ syncop_lookup (xlator_t *subvol, loc_t *loc, dict_t *xattr_req,
if (iatt)
*iatt = args.iatt1;
- if (xattr_rsp)
- *xattr_rsp = args.xattr;
if (parent)
*parent = args.iatt2;
+ if (xattr_rsp)
+ *xattr_rsp = args.xattr;
+ else if (args.xattr)
+ dict_unref (args.xattr);
errno = args.op_errno;
return args.op_ret;
@@ -400,6 +402,7 @@ syncop_readdirp (xlator_t *subvol,
if (entries)
list_splice_init (&args.entries.list, &entries->list);
+ /* TODO: need to free all the 'args.entries' in 'else' case */
errno = args.op_errno;
return args.op_ret;
@@ -509,7 +512,7 @@ syncop_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
args->op_ret = op_ret;
args->op_errno = op_errno;
if (op_ret >= 0)
- args->xattr = dict_ref (dict);
+ args->xattr = dict_ref (dict);
__wake (args);
@@ -526,6 +529,8 @@ syncop_listxattr (xlator_t *subvol, loc_t *loc, dict_t **dict)
if (dict)
*dict = args.xattr;
+ else if (args.xattr)
+ dict_unref (args.xattr);
errno = args.op_errno;
return args.op_ret;
@@ -541,6 +546,8 @@ syncop_getxattr (xlator_t *subvol, loc_t *loc, dict_t **dict, const char *key)
if (dict)
*dict = args.xattr;
+ else if (args.xattr)
+ dict_unref (args.xattr);
errno = args.op_errno;
return args.op_ret;
@@ -556,6 +563,8 @@ syncop_fgetxattr (xlator_t *subvol, fd_t *fd, dict_t **dict, const char *key)
if (dict)
*dict = args.xattr;
+ else if (args.xattr)
+ dict_unref (args.xattr);
errno = args.op_errno;
return args.op_ret;
@@ -732,6 +741,8 @@ syncop_readv (xlator_t *subvol, fd_t *fd, size_t size, off_t off,
if (vector)
*vector = args.vector;
+ else if (args.vector)
+ GF_FREE (args.vector);
if (count)
*count = args.count;
@@ -739,6 +750,8 @@ syncop_readv (xlator_t *subvol, fd_t *fd, size_t size, off_t off,
/* Do we need a 'ref' here? */
if (iobref)
*iobref = args.iobref;
+ else if (args.iobref)
+ iobref_unref (args.iobref);
errno = args.op_errno;
return args.op_ret;
@@ -1047,6 +1060,8 @@ syncop_readlink (xlator_t *subvol, loc_t *loc, char **buffer, size_t size)
if (buffer)
*buffer = args.buffer;
+ else if (args.buffer)
+ GF_FREE (args.buffer);
errno = args.op_errno;
return args.op_ret;