From c31ac73cd8e9ca4b872a48667e09019991dea00b Mon Sep 17 00:00:00 2001 From: Susant Palai Date: Fri, 11 Sep 2015 08:52:44 -0400 Subject: dht/cluster: Avoid crash if local is NULL This patch addresses crash handling if local is NULL. In addition to that, we were not unwinding if no lock is taken in dht_linkfile_create_cbk(create/mknod). This patch handles that also. Change-Id: Ibcff317f10d60e7865fd7ffb9479b3af53c9ef17 BUG: 1260051 Signed-off-by: Susant Palai Reviewed-on: http://review.gluster.org/12160 Reviewed-by: N Balachandran Tested-by: Gluster Build System Reviewed-by: Raghavendra G --- xlators/cluster/dht/src/dht-common.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'xlators/cluster/dht/src/dht-common.c') diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index c056872d7b4..9dc065617e9 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -5046,12 +5046,15 @@ dht_mknod_linkfile_create_cbk (call_frame_t *frame, void *cookie, goto err; } - if (op_ret == -1) + if (op_ret == -1) { + local->op_errno = op_errno; goto err; + } conf = this->private; if (!conf) { local->op_errno = EINVAL; + op_errno = EINVAL; goto err; } @@ -5069,9 +5072,13 @@ dht_mknod_linkfile_create_cbk (call_frame_t *frame, void *cookie, return 0; err: - if (local->lock.locks) + if (local && local->lock.locks) { local->refresh_layout_unlock (frame, this, -1, 0); - + } else { + DHT_STACK_UNWIND (mknod, frame, -1, + op_errno, NULL, NULL, NULL, + NULL, NULL); + } return 0; } @@ -5864,6 +5871,7 @@ dht_create_linkfile_create_cbk (call_frame_t *frame, void *cookie, conf = this->private; if (!conf) { local->op_errno = EINVAL; + op_errno = EINVAL; goto err; } @@ -5881,9 +5889,13 @@ dht_create_linkfile_create_cbk (call_frame_t *frame, void *cookie, return 0; err: - if (local->lock.locks) + if (local && local->lock.locks) { local->refresh_layout_unlock (frame, this, -1, 0); - + } else { + DHT_STACK_UNWIND (create, frame, -1, + op_errno, NULL, NULL, NULL, + NULL, NULL, NULL); + } return 0; } -- cgit