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