Blob Blame History Raw
From e100d3435a04f57ed54ff1f6a07ae76a1a4e0abb Mon Sep 17 00:00:00 2001
From: Ashish Pandey <aspandey@redhat.com>
Date: Fri, 2 Dec 2016 13:15:20 +0530
Subject: [PATCH 219/227] cluster/ec: Check xdata to avoid memory leak

Problem: ec_writev_start calls ec_make_internal_fop_xdata
to set "yes" in xdata before ec_readv (an internal fop)
is called for head and tail. Second call to this function
is overwriting the previous allocated dict_t to "xdata",
which results in memory leak.

Solution: In ec_make_internal_fop_xdata, check if *xdata
is NULL or not to avoid overwriting *xdata.

>Reviewed-on: http://review.gluster.org/16007
>Reviewed-by: Xavier Hernandez <xhernandez@datalab.es>
>Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
>Tested-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
>Smoke: Gluster Build System <jenkins@build.gluster.org>
>NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>

Change-Id: I49b83923e11aff9b92d002e86424c0c2e1f5f74f
BUG: 1399105
Signed-off-by: Ashish Pandey <aspandey@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/92048
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Tested-by: Atin Mukherjee <amukherj@redhat.com>
---
 xlators/cluster/ec/src/ec-inode-write.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/xlators/cluster/ec/src/ec-inode-write.c b/xlators/cluster/ec/src/ec-inode-write.c
index 6aeda5a..92c6b8a 100644
--- a/xlators/cluster/ec/src/ec-inode-write.c
+++ b/xlators/cluster/ec/src/ec-inode-write.c
@@ -1270,6 +1270,9 @@ ec_make_internal_fop_xdata (dict_t **xdata)
 {
     dict_t *dict = NULL;
 
+    if (*xdata)
+	return 0;
+
     dict = dict_new();
     if (!dict)
        goto out;
-- 
2.9.3