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