summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorPranith Kumar K <pkarampu@redhat.com>2019-09-07 20:18:01 +0530
committerPranith Kumar K <pkarampu@redhat.com>2019-09-07 20:20:09 +0530
commit6bf09ecbe8203d0f8c020e6b0b55202e91e216c9 (patch)
treeb14fe21d97272428cc43579000d6f5c651302edd /xlators
parent7b3971ad0152eb1bb89a982333970118a6bd4922 (diff)
cluster/ec: Fix coverity issues
Fixed the following coverity issue in both flush/fsync >>> CID 1404964: Null pointer dereferences (REVERSE_INULL) >>> Null-checking "fd" suggests that it may be null, but it has already been dereferenced on all paths leading to the check. >>> if (fd != NULL) { >>> fop->fd = fd_ref(fd); >>> if (fop->fd == NULL) { >>> gf_msg(this->name, GF_LOG_ERROR, 0, >>> "Failed to reference a " >>> "file descriptor."); fixes bz#1748836 Change-Id: I19c05d585e23f8fbfbc195d1f3775ec528eed671 Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/cluster/ec/src/ec-generic.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/xlators/cluster/ec/src/ec-generic.c b/xlators/cluster/ec/src/ec-generic.c
index 4cd47a83b84..884deb93669 100644
--- a/xlators/cluster/ec/src/ec-generic.c
+++ b/xlators/cluster/ec/src/ec-generic.c
@@ -193,12 +193,14 @@ ec_flush(call_frame_t *frame, xlator_t *this, uintptr_t target,
GF_VALIDATE_OR_GOTO(this->name, frame, out);
GF_VALIDATE_OR_GOTO(this->name, this->private, out);
- error = ec_validate_fd(fd, this);
- if (error) {
- gf_msg(this->name, GF_LOG_ERROR, EBADF, EC_MSG_FD_BAD,
- "Failing %s on %s", gf_fop_list[GF_FOP_FLUSH],
- fd->inode ? uuid_utoa(fd->inode->gfid) : "");
- goto out;
+ if (fd) {
+ error = ec_validate_fd(fd, this);
+ if (error) {
+ gf_msg(this->name, GF_LOG_ERROR, EBADF, EC_MSG_FD_BAD,
+ "Failing %s on %s", gf_fop_list[GF_FOP_FLUSH],
+ fd->inode ? uuid_utoa(fd->inode->gfid) : "");
+ goto out;
+ }
}
fop = ec_fop_data_allocate(frame, this, GF_FOP_FLUSH, 0, target, fop_flags,
@@ -417,12 +419,14 @@ ec_fsync(call_frame_t *frame, xlator_t *this, uintptr_t target,
GF_VALIDATE_OR_GOTO(this->name, frame, out);
GF_VALIDATE_OR_GOTO(this->name, this->private, out);
- error = ec_validate_fd(fd, this);
- if (error) {
- gf_msg(this->name, GF_LOG_ERROR, EBADF, EC_MSG_FD_BAD,
- "Failing %s on %s", gf_fop_list[GF_FOP_FSYNC],
- fd->inode ? uuid_utoa(fd->inode->gfid) : "");
- goto out;
+ if (fd) {
+ error = ec_validate_fd(fd, this);
+ if (error) {
+ gf_msg(this->name, GF_LOG_ERROR, EBADF, EC_MSG_FD_BAD,
+ "Failing %s on %s", gf_fop_list[GF_FOP_FSYNC],
+ fd->inode ? uuid_utoa(fd->inode->gfid) : "");
+ goto out;
+ }
}
fop = ec_fop_data_allocate(frame, this, GF_FOP_FSYNC, 0, target, fop_flags,