7f4c2a
From c3338a100dd9948d7c30c7b50f6cebf95fd6801e Mon Sep 17 00:00:00 2001
7f4c2a
From: Susant Palai <spalai@redhat.com>
7f4c2a
Date: Fri, 11 Sep 2015 08:52:44 -0400
7f4c2a
Subject: [PATCH 328/330] dht/cluster: Avoid crash if local is NULL
7f4c2a
7f4c2a
This patch addresses crash handling if local is NULL. In addition to that,
7f4c2a
we were not unwinding if no lock is taken in dht_linkfile_create_cbk(create/mknod).
7f4c2a
This patch handles that also.
7f4c2a
7f4c2a
BUG: 1259750
7f4c2a
Change-Id: I3f3dca5e88fba255e4c499f64c390da144a56590
7f4c2a
Signed-off-by: Susant Palai <spalai@redhat.com>
7f4c2a
Reviewed-on: https://code.engineering.redhat.com/gerrit/57617
7f4c2a
Reviewed-by: Nithya Balachandran <nbalacha@redhat.com>
7f4c2a
Reviewed-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
7f4c2a
Tested-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
7f4c2a
---
7f4c2a
 xlators/cluster/dht/src/dht-common.c |   20 +++++++++++++++++---
7f4c2a
 1 files changed, 17 insertions(+), 3 deletions(-)
7f4c2a
7f4c2a
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
7f4c2a
index 1d27fba..7f4ae48 100644
7f4c2a
--- a/xlators/cluster/dht/src/dht-common.c
7f4c2a
+++ b/xlators/cluster/dht/src/dht-common.c
7f4c2a
@@ -5033,12 +5033,15 @@ dht_mknod_linkfile_create_cbk (call_frame_t *frame, void *cookie,
7f4c2a
                 goto err;
7f4c2a
         }
7f4c2a
 
7f4c2a
-        if (op_ret == -1)
7f4c2a
+        if (op_ret == -1) {
7f4c2a
+                local->op_errno = op_errno;
7f4c2a
                 goto err;
7f4c2a
+        }
7f4c2a
 
7f4c2a
         conf = this->private;
7f4c2a
         if (!conf) {
7f4c2a
                 local->op_errno =  EINVAL;
7f4c2a
+                op_errno = EINVAL;
7f4c2a
                 goto err;
7f4c2a
         }
7f4c2a
 
7f4c2a
@@ -5056,8 +5059,13 @@ dht_mknod_linkfile_create_cbk (call_frame_t *frame, void *cookie,
7f4c2a
 
7f4c2a
         return 0;
7f4c2a
 err:
7f4c2a
-        if (local->lock.locks)
7f4c2a
+        if (local && local->lock.locks) {
7f4c2a
                 local->refresh_layout_unlock (frame, this, -1);
7f4c2a
+        } else {
7f4c2a
+                DHT_STACK_UNWIND (mknod, frame, -1,
7f4c2a
+                                  op_errno, NULL, NULL, NULL,
7f4c2a
+                                  NULL, NULL);
7f4c2a
+        }
7f4c2a
 
7f4c2a
         return 0;
7f4c2a
 }
7f4c2a
@@ -5850,6 +5858,7 @@ dht_create_linkfile_create_cbk (call_frame_t *frame, void *cookie,
7f4c2a
         conf = this->private;
7f4c2a
         if (!conf) {
7f4c2a
                 local->op_errno = EINVAL;
7f4c2a
+                op_errno = EINVAL;
7f4c2a
                 goto err;
7f4c2a
         }
7f4c2a
 
7f4c2a
@@ -5867,8 +5876,13 @@ dht_create_linkfile_create_cbk (call_frame_t *frame, void *cookie,
7f4c2a
 
7f4c2a
         return 0;
7f4c2a
 err:
7f4c2a
-        if (local->lock.locks)
7f4c2a
+        if (local && local->lock.locks) {
7f4c2a
                 local->refresh_layout_unlock (frame, this, -1);
7f4c2a
+        } else {
7f4c2a
+                DHT_STACK_UNWIND (create, frame, -1,
7f4c2a
+                                  op_errno, NULL, NULL, NULL,
7f4c2a
+                                  NULL, NULL, NULL);
7f4c2a
+        }
7f4c2a
 
7f4c2a
         return 0;
7f4c2a
 }
7f4c2a
-- 
7f4c2a
1.7.1
7f4c2a