From 20e86a1b4c733934ff9960314d06697ad05a4528 Mon Sep 17 00:00:00 2001 From: Manikandan Selvaganesh Date: Wed, 4 Feb 2015 12:14:52 +0530 Subject: afr : null dereference coverity fix. CID : 1194648 Change-Id: Ib26e7cdbf412d563240885fb3113bcc1fe5c9c49 BUG: 789278 Signed-off-by: Manikandan Selvaganesh Reviewed-on: http://review.gluster.org/9571 Tested-by: Gluster Build System Reviewed-by: Krutika Dhananjay Reviewed-by: Kaleb KEITHLEY --- xlators/cluster/afr/src/afr-common.c | 39 +++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c index efe8f8bc435..5654e3ad03d 100644 --- a/xlators/cluster/afr/src/afr-common.c +++ b/xlators/cluster/afr/src/afr-common.c @@ -328,14 +328,16 @@ afr_inode_read_subvol_get (inode_t *inode, xlator_t *this, unsigned char *data, { int ret = -1; - LOCK(&inode->lock); + GF_VALIDATE_OR_GOTO (this->name, inode, out); + + LOCK(&inode->lock); { ret = __afr_inode_read_subvol_get (inode, this, data, metadata, event_p); } UNLOCK(&inode->lock); - - return ret; +out: + return ret; } int @@ -344,14 +346,16 @@ afr_inode_split_brain_choice_get (inode_t *inode, xlator_t *this, { int ret = -1; + GF_VALIDATE_OR_GOTO (this->name, inode, out); + LOCK(&inode->lock); { ret = __afr_inode_split_brain_choice_get (inode, this, spb_choice); } UNLOCK(&inode->lock); - - return ret; +out: + return ret; } @@ -361,29 +365,34 @@ afr_inode_read_subvol_set (inode_t *inode, xlator_t *this, unsigned char *data, { int ret = -1; - LOCK(&inode->lock); + GF_VALIDATE_OR_GOTO (this->name, inode, out); + + LOCK(&inode->lock); { ret = __afr_inode_read_subvol_set (inode, this, data, metadata, event); } UNLOCK(&inode->lock); - - return ret; +out: + return ret; } + int afr_inode_split_brain_choice_set (inode_t *inode, xlator_t *this, int spb_choice) { int ret = -1; + GF_VALIDATE_OR_GOTO (this->name, inode, out); + LOCK(&inode->lock); { ret = __afr_inode_split_brain_choice_set (inode, this, spb_choice); } UNLOCK(&inode->lock); - +out: return ret; } @@ -393,12 +402,14 @@ afr_inode_read_subvol_reset (inode_t *inode, xlator_t *this) { int ret = -1; - LOCK(&inode->lock); - { - ret = __afr_inode_read_subvol_reset (inode, this); - } - UNLOCK(&inode->lock); + GF_VALIDATE_OR_GOTO (this->name, inode, out); + LOCK(&inode->lock); + { + ret = __afr_inode_read_subvol_reset (inode, this); + } + UNLOCK(&inode->lock); +out: return ret; } -- cgit