From 65bd1e2f94781bea5ad6eeb5b4d9f9f614660085 Mon Sep 17 00:00:00 2001 From: Ashish Pandey Date: Tue, 18 Sep 2018 17:09:28 +0530 Subject: storage/posix: Check if fd->inode is NULL before using it CID: 1395473, 1395472 https://scan6.coverity.com/reports.htm#v42607/p10714/fileInstanceId=85588219&defectInstanceId=26115956&mergedDefectId=1395472 https://scan6.coverity.com/reports.htm#v42607/p10714/fileInstanceId=85588219&defectInstanceId=26115961&mergedDefectId=1395473 Change-Id: I2c3cc350e0ac156616df6f568ba28dbfa68064bf updates: bz#789278 Signed-off-by: Ashish Pandey --- xlators/storage/posix/src/posix-inode-fd-ops.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'xlators') diff --git a/xlators/storage/posix/src/posix-inode-fd-ops.c b/xlators/storage/posix/src/posix-inode-fd-ops.c index 2cb65d7fd0e..4b6716fcd7f 100644 --- a/xlators/storage/posix/src/posix-inode-fd-ops.c +++ b/xlators/storage/posix/src/posix-inode-fd-ops.c @@ -1522,13 +1522,13 @@ posix_readv(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, VALIDATE_OR_GOTO(frame, out); VALIDATE_OR_GOTO(this, out); VALIDATE_OR_GOTO(fd, out); + VALIDATE_OR_GOTO(fd->inode, out); VALIDATE_OR_GOTO(this->private, out); priv = this->private; VALIDATE_OR_GOTO(priv, out); - if (fd->inode && ((fd->inode->ia_type == IA_IFBLK) || - (fd->inode->ia_type == IA_IFCHR))) { + if ((fd->inode->ia_type == IA_IFBLK) || (fd->inode->ia_type == IA_IFCHR)) { gf_msg(this->name, GF_LOG_ERROR, EINVAL, P_MSG_INVALID_ARGUMENT, "readv received on a block/char file (%s)", uuid_utoa(fd->inode->gfid)); @@ -1798,6 +1798,7 @@ posix_writev(call_frame_t *frame, xlator_t *this, fd_t *fd, VALIDATE_OR_GOTO(frame, out); VALIDATE_OR_GOTO(this, out); VALIDATE_OR_GOTO(fd, out); + VALIDATE_OR_GOTO(fd->inode, out); VALIDATE_OR_GOTO(vector, out); VALIDATE_OR_GOTO(this->private, out); @@ -1806,8 +1807,7 @@ posix_writev(call_frame_t *frame, xlator_t *this, fd_t *fd, VALIDATE_OR_GOTO(priv, out); DISK_SPACE_CHECK_AND_GOTO(frame, priv, xdata, op_ret, op_errno, out); - if (fd->inode && ((fd->inode->ia_type == IA_IFBLK) || - (fd->inode->ia_type == IA_IFCHR))) { + if ((fd->inode->ia_type == IA_IFBLK) || (fd->inode->ia_type == IA_IFCHR)) { gf_msg(this->name, GF_LOG_ERROR, EINVAL, P_MSG_INVALID_ARGUMENT, "writev received on a block/char file (%s)", uuid_utoa(fd->inode->gfid)); -- cgit