summaryrefslogtreecommitdiffstats
path: root/xlators/cluster
diff options
context:
space:
mode:
authorAshish Pandey <aspandey@redhat.com>2017-11-04 19:20:35 +0530
committerAmar Tumballi <amarts@redhat.com>2017-11-06 07:05:31 +0000
commitaf8604d5e9826df57aee7aba235d2e77a7e7f8fb (patch)
tree236089e44c68340bc93cae1596ffec784a0d5791 /xlators/cluster
parentf461d75b226a5bc6c088280e43a96f9b54f33af5 (diff)
cluster/dht: Check for NULL before using variable
Coverity ID: 245 Check statvfs received as cbk before using it Coverity ID: 228 Check NULL loc before freeing it. Change-Id: I1b153ed5e7b81bcf7033bf710808e95908dcfef4 BUG: 789278 Signed-off-by: Ashish Pandey <aspandey@redhat.com>
Diffstat (limited to 'xlators/cluster')
-rw-r--r--xlators/cluster/dht/src/dht-diskusage.c6
-rw-r--r--xlators/cluster/dht/src/dht-helper.c4
2 files changed, 6 insertions, 4 deletions
diff --git a/xlators/cluster/dht/src/dht-diskusage.c b/xlators/cluster/dht/src/dht-diskusage.c
index 05592154e30..b1de9ff44aa 100644
--- a/xlators/cluster/dht/src/dht-diskusage.c
+++ b/xlators/cluster/dht/src/dht-diskusage.c
@@ -38,14 +38,14 @@ dht_du_info_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
conf = this->private;
prev = cookie;
- if (op_ret == -1) {
+ if (op_ret == -1 || !statvfs) {
gf_msg (this->name, GF_LOG_WARNING, op_errno,
DHT_MSG_GET_DISK_INFO_ERROR,
"failed to get disk info from %s", prev->name);
goto out;
}
- if (statvfs && statvfs->f_blocks) {
+ if (statvfs->f_blocks) {
percent = (statvfs->f_bavail * 100) / statvfs->f_blocks;
bytes = (statvfs->f_bavail * statvfs->f_frsize);
/*
@@ -60,7 +60,7 @@ dht_du_info_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
chunks = (statvfs->f_blocks + bpc - 1) / bpc;
}
- if (statvfs && statvfs->f_files) {
+ if (statvfs->f_files) {
percent_inodes = (statvfs->f_ffree * 100) / statvfs->f_files;
} else {
/*
diff --git a/xlators/cluster/dht/src/dht-helper.c b/xlators/cluster/dht/src/dht-helper.c
index 5c3d37ad104..0c249f0e84c 100644
--- a/xlators/cluster/dht/src/dht-helper.c
+++ b/xlators/cluster/dht/src/dht-helper.c
@@ -1158,7 +1158,9 @@ dht_build_child_loc (xlator_t *this, loc_t *child, loc_t *parent, char *name)
return 0;
err:
- loc_wipe (child);
+ if (child) {
+ loc_wipe (child);
+ }
return -1;
}