summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShyamsundarR <srangana@redhat.com>2018-11-30 11:58:57 -0500
committerAmar Tumballi <amarts@redhat.com>2018-12-03 05:47:21 +0000
commit0b54c92a22c89fd1d8e03cad2dfb70a5b73ee12a (patch)
tree8c631c2cc9e741f453a075418a835f6fb0b86f8e
parent0566ecc878adc5a5aba2c3210485087a9a67da59 (diff)
clang: Fix io-stats.c NULL pointer issue reported by clang
The issue pertains to checking if conf is NULL in BUMP_FOP but not providing that safety in io_stats_release when using conf to lock and bump nr_opens. This is now corrected to check if conf is non-NULL before attempting the lock and bump nr_opens. Tested with local clang analyzer to ensure this fixes the problem. Change-Id: Iffd6a97c2060d0a6930a8dc5914b1956c192cab1 Updates: bz#1622665 Signed-off-by: ShyamsundarR <srangana@redhat.com>
-rw-r--r--xlators/debug/io-stats/src/io-stats.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/xlators/debug/io-stats/src/io-stats.c b/xlators/debug/io-stats/src/io-stats.c
index 06a16c8f3e6..29c9af6f3c5 100644
--- a/xlators/debug/io-stats/src/io-stats.c
+++ b/xlators/debug/io-stats/src/io-stats.c
@@ -3450,12 +3450,13 @@ io_stats_release(xlator_t *this, fd_t *fd)
BUMP_FOP(RELEASE);
conf = this->private;
-
- LOCK(&conf->lock);
- {
- conf->cumulative.nr_opens--;
+ if (conf) {
+ LOCK(&conf->lock);
+ {
+ conf->cumulative.nr_opens--;
+ }
+ UNLOCK(&conf->lock);
}
- UNLOCK(&conf->lock);
ios_fd_ctx_get(fd, this, &iosfd);
if (iosfd) {