f338ef
From 58070aa568ffbaac267b02428e974b2459ae13b0 Mon Sep 17 00:00:00 2001
f338ef
From: Susant Palai <spalai@redhat.com>
f338ef
Date: Tue, 18 Jun 2019 16:43:43 +0530
f338ef
Subject: [PATCH 197/221] :posix: fix crash in posix_cs_set_state
f338ef
f338ef
> Fixes: bz#1721474
f338ef
> Change-Id: Ic2a53fa3d1e9e23424c6898e0986f80d52c5e3f6
f338ef
> Signed-off-by: Susant Palai <spalai@redhat.com>
f338ef
(cherry-pick of https://review.gluster.org/#/c/glusterfs/+/22892/)
f338ef
f338ef
BUG: 1721477
f338ef
Change-Id: Ic2a53fa3d1e9e23424c6898e0986f80d52c5e3f6
f338ef
Signed-off-by: Susant Palai <spalai@redhat.com>
f338ef
Reviewed-on: https://code.engineering.redhat.com/gerrit/173936
f338ef
Tested-by: RHGS Build Bot <nigelb@redhat.com>
f338ef
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
f338ef
---
f338ef
 xlators/storage/posix/src/posix-helpers.c      | 5 +++++
f338ef
 xlators/storage/posix/src/posix-inode-fd-ops.c | 7 ++++---
f338ef
 2 files changed, 9 insertions(+), 3 deletions(-)
f338ef
f338ef
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
f338ef
index aecf4f8..849db3d 100644
f338ef
--- a/xlators/storage/posix/src/posix-helpers.c
f338ef
+++ b/xlators/storage/posix/src/posix-helpers.c
f338ef
@@ -3235,6 +3235,11 @@ posix_cs_set_state(xlator_t *this, dict_t **rsp, gf_cs_obj_state state,
f338ef
     char *value = NULL;
f338ef
     size_t xattrsize = 0;
f338ef
 
f338ef
+    if (!rsp) {
f338ef
+        ret = -1;
f338ef
+        goto out;
f338ef
+    }
f338ef
+
f338ef
     if (!(*rsp)) {
f338ef
         *rsp = dict_new();
f338ef
         if (!(*rsp)) {
f338ef
diff --git a/xlators/storage/posix/src/posix-inode-fd-ops.c b/xlators/storage/posix/src/posix-inode-fd-ops.c
f338ef
index 7ca4d26..b92c411 100644
f338ef
--- a/xlators/storage/posix/src/posix-inode-fd-ops.c
f338ef
+++ b/xlators/storage/posix/src/posix-inode-fd-ops.c
f338ef
@@ -1028,6 +1028,7 @@ posix_glfallocate(call_frame_t *frame, xlator_t *this, fd_t *fd,
f338ef
     struct iatt statpost = {
f338ef
         0,
f338ef
     };
f338ef
+    dict_t *rsp_xdata = NULL;
f338ef
 
f338ef
 #ifdef FALLOC_FL_KEEP_SIZE
f338ef
     if (keep_size)
f338ef
@@ -1035,15 +1036,15 @@ posix_glfallocate(call_frame_t *frame, xlator_t *this, fd_t *fd,
f338ef
 #endif /* FALLOC_FL_KEEP_SIZE */
f338ef
 
f338ef
     ret = posix_do_fallocate(frame, this, fd, flags, offset, len, &statpre,
f338ef
-                             &statpost, xdata, NULL);
f338ef
+                             &statpost, xdata, &rsp_xdata);
f338ef
     if (ret < 0)
f338ef
         goto err;
f338ef
 
f338ef
-    STACK_UNWIND_STRICT(fallocate, frame, 0, 0, &statpre, &statpost, NULL);
f338ef
+    STACK_UNWIND_STRICT(fallocate, frame, 0, 0, &statpre, &statpost, rsp_xdata);
f338ef
     return 0;
f338ef
 
f338ef
 err:
f338ef
-    STACK_UNWIND_STRICT(fallocate, frame, -1, -ret, NULL, NULL, NULL);
f338ef
+    STACK_UNWIND_STRICT(fallocate, frame, -1, -ret, NULL, NULL, rsp_xdata);
f338ef
     return 0;
f338ef
 }
f338ef
 
f338ef
-- 
f338ef
1.8.3.1
f338ef