From 0b54c92a22c89fd1d8e03cad2dfb70a5b73ee12a Mon Sep 17 00:00:00 2001 From: ShyamsundarR Date: Fri, 30 Nov 2018 11:58:57 -0500 Subject: 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 --- xlators/debug/io-stats/src/io-stats.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'xlators/debug/io-stats') 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) { -- cgit