diff options
author | Ashish Pandey <aspandey@redhat.com> | 2017-11-04 19:20:35 +0530 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2017-11-06 07:05:31 +0000 |
commit | af8604d5e9826df57aee7aba235d2e77a7e7f8fb (patch) | |
tree | 236089e44c68340bc93cae1596ffec784a0d5791 /xlators/cluster/dht/src/dht-diskusage.c | |
parent | f461d75b226a5bc6c088280e43a96f9b54f33af5 (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/dht/src/dht-diskusage.c')
-rw-r--r-- | xlators/cluster/dht/src/dht-diskusage.c | 6 |
1 files changed, 3 insertions, 3 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 { /* |