From: "Gustavo A. R. Silva" <garsilva@embeddedor.com>
To: David Howells <dhowells@redhat.com>
Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org,
"Gustavo A. R. Silva" <garsilva@embeddedor.com>
Subject: Logically dead code at fs/afs/cell.c:206
Date: Fri, 17 Nov 2017 15:57:32 -0600 [thread overview]
Message-ID: <20171117215732.GA15974@embeddedor.com> (raw)
Hi David,
Today Coverity reported a "Logically dead code" issue at fs/afs/cell.c:206:
if (!excl) {
rcu_read_lock();
cell = afs_lookup_cell_rcu(net, name, namesz);
rcu_read_unlock();
if (!IS_ERR(cell)) {
if (excl) {
afs_put_cell(net, cell);
return ERR_PTR(-EEXIST);
}
goto wait_for_cell;
}
}
The problem is that when this code block is executed, the code block starting at line 211 makes no sense, as _excl_ can never be true.
I was wondering if the original intention was to null check _cell_ instead of checking _excl_. So I took a look into function afs_lookup_cell_rcu to see if _cell_ can be returned as a null pointer and at the same time the if condition at line 210 be true, but I couldn't see how that could be possible. It seems to me that when _ret_ is equal to zero, _cell_ cannot be null in afs_lookup_cell_rcu. But is case I'm wrong here and _cell_ could be null at line 210, then I think line 211 should be changed as follows:
diff --git a/fs/afs/cell.c b/fs/afs/cell.c
index 1858c91..a69a11f 100644
--- a/fs/afs/cell.c
+++ b/fs/afs/cell.c
@@ -208,7 +208,7 @@ struct afs_cell *afs_lookup_cell(struct afs_net *net,
cell = afs_lookup_cell_rcu(net, name, namesz);
rcu_read_unlock();
if (!IS_ERR(cell)) {
- if (excl) {
+ if (cell) {
afs_put_cell(net, cell);
return ERR_PTR(-EEXIST);
}
But I'm suspicious about it.
What do you think?
Thanks
--
Gustavo A. R. Silva
next reply other threads:[~2017-11-17 21:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-17 21:57 Gustavo A. R. Silva [this message]
2017-11-17 22:21 ` Logically dead code at fs/afs/cell.c:206 David Howells
2017-11-17 22:26 ` Gustavo A. R. Silva
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171117215732.GA15974@embeddedor.com \
--to=garsilva@embeddedor.com \
--cc=dhowells@redhat.com \
--cc=linux-afs@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).