From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936618AbdKQV5m (ORCPT ); Fri, 17 Nov 2017 16:57:42 -0500 Received: from gateway23.websitewelcome.com ([192.185.48.84]:26756 "EHLO gateway23.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936602AbdKQV5h (ORCPT ); Fri, 17 Nov 2017 16:57:37 -0500 Date: Fri, 17 Nov 2017 15:57:32 -0600 From: "Gustavo A. R. Silva" To: David Howells Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: Logically dead code at fs/afs/cell.c:206 Message-ID: <20171117215732.GA15974@embeddedor.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 189.175.248.21 X-Source-L: No X-Exim-ID: 1eFodh-000buN-Br X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (embeddedor) [189.175.248.21]:34766 X-Source-Auth: garsilva@embeddedor.com X-Email-Count: 3 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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