diff options
author | N Balachandran <nbalacha@redhat.com> | 2017-08-24 13:39:07 +0530 |
---|---|---|
committer | Raghavendra G <rgowdapp@redhat.com> | 2017-08-28 06:42:27 +0000 |
commit | 414d3e92fc56f08e320a3aa65b6b18e65b384551 (patch) | |
tree | d4897cf1f8b81260752777bf8545c034734493a7 /xlators/performance/quick-read/src/quick-read.c | |
parent | ea48cae5df118d9b901e7d79cd8726b6f38d65a0 (diff) |
perf/qr: Use a ref-ed data to extract content
qr_content_extract used dict_get to get the value of
the GF_CONTENT_KEY key. dict_get does not ref the data
before returning it so QR could be acting on freed memory
if another thread deletes the key before then.
This patch also fixes a race in dict_get_with_ref.
Fix: Use dict_get_with_ref to retrieve the file contents.
Change-Id: Ib1a7a70bb92eed7e70747ec530e0b3edc53127ec
BUG: 1484709
Signed-off-by: N Balachandran <nbalacha@redhat.com>
Reviewed-on: https://review.gluster.org/18115
Smoke: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Tested-by: Raghavendra G <rgowdapp@redhat.com>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
Diffstat (limited to 'xlators/performance/quick-read/src/quick-read.c')
-rw-r--r-- | xlators/performance/quick-read/src/quick-read.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/xlators/performance/quick-read/src/quick-read.c b/xlators/performance/quick-read/src/quick-read.c index 8edf495fcdd..92b2f8266ea 100644 --- a/xlators/performance/quick-read/src/quick-read.c +++ b/xlators/performance/quick-read/src/quick-read.c @@ -268,17 +268,19 @@ qr_content_extract (dict_t *xdata) data_t *data = NULL; void *content = NULL; - data = dict_get (xdata, GF_CONTENT_KEY); + dict_get_with_ref (xdata, GF_CONTENT_KEY, &data); if (!data) return NULL; content = GF_CALLOC (1, data->len, gf_qr_mt_content_t); if (!content) - return NULL; + goto out; memcpy (content, data->data, data->len); - return content; +out: + data_unref (data); + return content; } |