From c932c0df4b70abaa85354e56efe6f1ce88ce4a38 Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Thu, 23 Feb 2017 21:26:33 +0100 Subject: shared: simplify and fix crash when we run out of memory Since mem_get0 can return NULL, local->op_ret is gonna crash. Found by coverity. And since we only have ENOMEM as potential error, we can also simplify the code by avoiding using 'local' for that. Change-Id: I778747b57f520b1a52347c0fc9f27efd7a7c5ca0 BUG: 789278 Signed-off-by: Michael Scherer Reviewed-on: https://review.gluster.org/16739 Smoke: Gluster Build System Tested-by: Michael Scherer NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Vijay Bellur Reviewed-by: Krutika Dhananjay Reviewed-by: Pranith Kumar Karampuri --- xlators/features/shard/src/shard.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'xlators/features/shard') diff --git a/xlators/features/shard/src/shard.c b/xlators/features/shard/src/shard.c index 0fcbbaff3e3..074a497d0dc 100644 --- a/xlators/features/shard/src/shard.c +++ b/xlators/features/shard/src/shard.c @@ -4232,8 +4232,6 @@ shard_readdir_do (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, local = mem_get0 (this->local_pool); if (!local) { - local->op_ret = -1; - local->op_errno = ENOMEM; goto err; } @@ -4260,8 +4258,6 @@ shard_readdir_do (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, "dict value: key:%s, directory gfid=%s", GF_XATTR_SHARD_BLOCK_SIZE, uuid_utoa (fd->inode->gfid)); - local->op_ret = -1; - local->op_errno = ENOMEM; goto err; } @@ -4273,7 +4269,7 @@ shard_readdir_do (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, return 0; err: - STACK_UNWIND_STRICT (readdir, frame, local->op_ret, local->op_errno, + STACK_UNWIND_STRICT (readdir, frame, -1, ENOMEM, NULL, NULL); return 0; -- cgit