Received: by 10.223.164.202 with SMTP id h10csp1816236wrb; Sat, 18 Nov 2017 06:50:16 -0800 (PST) X-Google-Smtp-Source: AGs4zMaBZjpPol5g2gQ55VbPiVVZh8jp7V42sDYGj0dYTUN6LNRWT4rMDOs4VaOcj//2H/xrPK7E X-Received: by 10.99.133.200 with SMTP id u191mr8324111pgd.327.1511016616115; Sat, 18 Nov 2017 06:50:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511016616; cv=none; d=google.com; s=arc-20160816; b=n7L7qt2Crhp2Ht+6CP6KV+D5ajYOBE7JpweCIo+dlb75hn2ClN76h7XDHQ6loA10Df U7V5Dh6b9spJU0UXFN0US5gGuTai91CaEvHm1a2ZWg5wdrkwXHm2PTmvnnNMt5J53NyC nl7X8nRx8YDjnKdzBsH9qRRyx/rmVHrc96LH4wrc28SI9DE7GLTsex9UVeqt2ZwH+tK2 0pEQwJHoFZsVWcHZMymoONif0zlulMDjq1oeJPg+F3INoS83JTFXR/4hoVIqUUzw6hXw DMCp7xXWcAtYLaB/5mqJCM0JPkdtiKw5Olx3PD8/MTwBjwEBDnDTsK90PmNNhNeQcpvZ zYTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date :arc-authentication-results; bh=4tdSGD/9FUy5iIOOY1LI9j86yv+NuIHKj1CPTZJS4Ic=; b=FmDxUIrJmc3pDAIBjKg9VGQhcNxNxvz6mGc74jeuI4mcOjQrLdVIkbdDmkUYPWOTPR Cg0v+J56Vw/uGB2S7+e90282FKgCOw7WaK1mTUxTyq9iLJ0Pw77qfYFKQUDxK7DrtGRa WWWq9mlIbq1rJlU9XUwFQHVbbVrmEDkXAnYfF/ELWPyH2PmCy00Ew90e6i4VJeZYSXQ/ 5sFdA2dvkJl9HceAxDjxg8GQibYfOM9/8K7vbuis9GgaGAPc3jScFb820GzdfnOptKNL qpo6W1WgpIXK5dWrUNo7T6QBoQ2TPWuoddwWhaZuhEBQ9lYTgVtZNs3AWN/RmkmtEvZ3 fsrw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k4si4626808pgp.422.2017.11.18.06.50.03; Sat, 18 Nov 2017 06:50:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936615AbdKQV5m (ORCPT + 93 others); 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 Received: from cm12.websitewelcome.com (cm12.websitewelcome.com [100.42.49.8]) by gateway23.websitewelcome.com (Postfix) with ESMTP id B5E154427 for ; Fri, 17 Nov 2017 15:57:33 -0600 (CST) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id FodheLBa5DL8rFodhe7q0s; Fri, 17 Nov 2017 15:57:33 -0600 Received: from [189.175.248.21] (port=34766 helo=embeddedor) by gator4166.hostgator.com with esmtpa (Exim 4.87) (envelope-from ) id 1eFodh-000buN-Br; Fri, 17 Nov 2017 15:57:33 -0600 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 Precedence: bulk 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 From 1586076955004605591@xxx Wed Dec 06 22:54:15 +0000 2017 X-GM-THRID: 1585946427959255769 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread