Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4801626imu; Sun, 25 Nov 2018 10:27:00 -0800 (PST) X-Google-Smtp-Source: AFSGD/U+ExpxzQOoUVhTfd7dZeQIpqx8qPZfn/mUpeon0470v662fB9Cj3GzBOzazU8IhIMcPSAz X-Received: by 2002:a63:a064:: with SMTP id u36mr21925943pgn.145.1543170420092; Sun, 25 Nov 2018 10:27:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543170420; cv=none; d=google.com; s=arc-20160816; b=mjynOFzFgOl1OrXcEta6aZ2Ho6aVL4RQYqmWpYiQ5dcXMfWk+E+aiAyyvF/olydUQs SU7atPAURmCs7iX9x4VdM/ozmcpR93e+jFJKlpQs+O6I9mASrn1/8RvJz4maczACxTDM FGfGJKxqVX6XG9jkEtVZohRpi26NQOTmA5GcTqCCH/juq4dsOx4uW8Na9yHbWs/nNfbx poMIxyAhPYHcko8VDFA+cecMSHTr/y4ztLMeSkpsaJmE/q/Ta3r1mmnw1FbfrOHhUoFa unl4y8OJq4CAZLYEHoJx2u3EfFPNkXjCrIH5DKIFYtKHeqMoigW7Of7aaOOjMniYekM3 LLNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:from:subject:cc:to:message-id:date; bh=LfGymoT/o27rK8xfhiUifesm1nPxlrF4NS182W9Hzh0=; b=nKSaN8WT5XbRre7bfCRwnRCwqyouHVsnyegwz9KWv5xI1XAoWkZMMvYoKppgeyxCm7 QnetnPSSRULdAQDqC10dfDZ7+Jomo4IayuU4moWXp0r5aYrZyEXg1KTWsNilTF0ZS/qP SFv4GmZLS0iYT1+aauZqnHvFKC1aW0nDYl1aNnobEQ/CzEWQ0vIIuWlZVDWqZ4alhtOV +brdMGVKRc7CU09FI+ct7R3qAH0kiC/k71NTiNCyn+ciTRGmkVEiiawgQIB+COVbFTSw fzcMROT6RF55VqzfWoJ2Rh6Ey2i/wRnje4DQ1/1tGr+LrWt4MySTxRTyMLodvdkTA93a vHLA== 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 u22si25103914pgh.286.2018.11.25.10.26.43; Sun, 25 Nov 2018 10:27:00 -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 S1726380AbeKZFRr (ORCPT + 99 others); Mon, 26 Nov 2018 00:17:47 -0500 Received: from shards.monkeyblade.net ([23.128.96.9]:44528 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725838AbeKZFRr (ORCPT ); Mon, 26 Nov 2018 00:17:47 -0500 Received: from localhost (unknown [IPv6:2601:601:9f80:35cd::bf5]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: davem-davemloft) by shards.monkeyblade.net (Postfix) with ESMTPSA id DCE5814CFA111; Sun, 25 Nov 2018 10:26:07 -0800 (PST) Date: Sun, 25 Nov 2018 10:26:07 -0800 (PST) Message-Id: <20181125.102607.771941500171801961.davem@davemloft.net> To: colin.king@canonical.com Cc: roopa@cumulusnetworks.com, nikolay@cumulusnetworks.com, bridge@lists.linux-foundation.org, netdev@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH][V2] net: bridge: remove redundant checks for null p->dev and p->br From: David Miller In-Reply-To: <20181125160851.6919-1-colin.king@canonical.com> References: <20181125160851.6919-1-colin.king@canonical.com> X-Mailer: Mew version 6.8 on Emacs 26.1 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Sun, 25 Nov 2018 10:26:08 -0800 (PST) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin King Date: Sun, 25 Nov 2018 16:08:51 +0000 > From: Colin Ian King > > A recent change added a null check on p->dev after p->dev was being > dereferenced by the ns_capable check on p->dev. It turns out that > neither the p->dev and p->br null checks are necessary, and can be > removed, which cleans up a static analyis warning. > > As Nikolay Aleksandrov noted, these checks can be removed because: > > "My reasoning of why it shouldn't be possible: > - On port add new_nbp() sets both p->dev and p->br before creating > kobj/sysfs > > - On port del (trickier) del_nbp() calls kobject_del() before call_rcu() > to destroy the port which in turn calls sysfs_remove_dir() which uses > kernfs_remove() which deactivates (shouldn't be able to open new > files) and calls kernfs_drain() to drain current open/mmaped files in > the respective dir before continuing, thus making it impossible to > open a bridge port sysfs file with p->dev and p->br equal to NULL. > > So I think it's safe to remove those checks altogether. It'd be nice to > get a second look over my reasoning as I might be missing something in > sysfs/kernfs call path." > > Thanks to Nikolay Aleksandrov's suggestion to remove the check and > David Miller for sanity checking this. > > Detected by CoverityScan, CID#751490 ("Dereference before null check") > > Fixes: a5f3ea54f3cc ("net: bridge: add support for raw sysfs port options") > Signed-off-by: Colin Ian King Applied.