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