Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1959909rda; Tue, 24 Oct 2023 08:16:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHB/vqi00J8Vv2sbk97zKhcNZoS74pHqZ0mtcYjElD04gqLumkopK0wLRxnxk5/m/odMtkS X-Received: by 2002:a17:903:32c9:b0:1ca:8b74:17ff with SMTP id i9-20020a17090332c900b001ca8b7417ffmr13088613plr.26.1698160600984; Tue, 24 Oct 2023 08:16:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698160600; cv=none; d=google.com; s=arc-20160816; b=de8rDg2beYV578r9DQ7vPzmwizL/uq2xGzubdymDMzb5dDvadnnUYpWS0ElqPlefGe dkq/45RavQCRCcwsjdh2i+W71sf2tGIjIRrreb7cf9/jGonshVckPKxzBtNfwlAAOijt ukjp2aSD+sfJramggyPChG+lf1zcwl03cG2d54HFCPgYiWjtY5cwDyJsiAIfNhJdavrs DgTrypPJ06259zuIA2IToPP8gffNkYaeTJj6CJUeaK2GagAcv/GjzOBpV/6/bhni0tQr N2qNqai3C7tVyKg7E4vG/dmm62LIoR5bzOAYQ+SwWmDGHRjRnrYfzSO6xxA2vlR54qoj y5rA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=sH+b3t/Lg4sPCX/xMGn6wucQyH0T1dLOIFfBFYW1nrg=; fh=VWmZ+o7KvMGZgl9WyysAfcidM0tMaxqJIkWtjXXExbM=; b=vLl0ur/M+9eNHEW6Y+hKVAtktZrPq8bCZ6oWeWCdJjzBkc72VQJ5Ng2J3nPYah7T4R uRifw9CJsI/X/hMguBTH/vbQ8WY5qPjjla/WoRHavdfXSfNqOAc+DKAf70K68Vzn5U9m GhUus8NSJlJND3rVmJplRIUnf1p+C7RwuNuwbkU7XLQSMV+oW9U4hdQxdVNmpyqIRJ2x 1FDp53/Nmf0HlkBuLH4S0p9mOKoUB/yMKdsye8xfh0QjThuMIid8GgfznoBMGt8w9x4k cEDbkBY/MxWuz08U7HdBBdaMjiqtAXxIsnTaq8+UW62FQ5RZCUnSnUsCrlw6M7loT4Ue LvFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XPq9hWlX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id 4-20020a170902e9c400b001baff05d890si8099353plk.313.2023.10.24.08.16.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 08:16:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XPq9hWlX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id EB3F4802BE6C; Tue, 24 Oct 2023 08:16:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233762AbjJXPQg (ORCPT + 99 others); Tue, 24 Oct 2023 11:16:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233646AbjJXPQ3 (ORCPT ); Tue, 24 Oct 2023 11:16:29 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83F93EA; Tue, 24 Oct 2023 08:16:26 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 936FDC433CD; Tue, 24 Oct 2023 15:16:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698160586; bh=/C6E6tZNLUaoLoiYdGV1pjU5ihBkYuq/xjH5Z7ZWGMA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XPq9hWlX7HZJM1/Td4WXD6mSoaAVDSCjY0mEfEMvjtc3jYDQcxTEbdxj9mr02UrdW NB9pInQWEb6VkuGnBIAQyfIxYQtEIUIadXnp75HUE3Y8tiopfjgF9EIeMXOzGsnaUD zE4dcvlV2l4GYHjQ+XhKg6F3pbW6mmb+NcdCnBtEfxaT71Q/kVyoAJ2QL/vQiyCjk+ nDxy0t8OEKoIQw6wO/cn4spmC+CIgufdmbbcvdgFjF48IuQWYS8MLSnUfFuwvJY/Wi 8zz4kE1IUU4W8PpGjzgWwx+IH0H/g4ZvEjZiNIL9aHRsBaZjWSHLfHKajrOPxuT8La Cxla92Qx+bhZA== Date: Tue, 24 Oct 2023 18:16:21 +0300 From: Leon Romanovsky To: Yang Li Cc: jgg@ziepe.ca, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, Abaci Robot Subject: Re: [PATCH -next] RDMA/core: Remove NULL check before dev_{put, hold} Message-ID: <20231024151621.GB1939579@unreal> References: <20231024003815.89742-1-yang.lee@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231024003815.89742-1-yang.lee@linux.alibaba.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 24 Oct 2023 08:16:40 -0700 (PDT) On Tue, Oct 24, 2023 at 08:38:15AM +0800, Yang Li wrote: > The call netdev_{put, hold} of dev_{put, hold} will check NULL, > so there is no need to check before using dev_{put, hold}, > remove it to silence the warning: > > ./drivers/infiniband/core/nldev.c:375:2-9: WARNING: NULL check before dev_{put, hold} functions is not needed. > > Reported-by: Abaci Robot > Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=7047 > Signed-off-by: Yang Li > --- > drivers/infiniband/core/nldev.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) I added the following hunk and applied the patch. diff --git a/drivers/infiniband/core/lag.c b/drivers/infiniband/core/lag.c index c77d7d2559a1..eca6e37c72ba 100644 --- a/drivers/infiniband/core/lag.c +++ b/drivers/infiniband/core/lag.c @@ -102,8 +102,7 @@ static struct net_device *rdma_get_xmit_slave_udp(struct ib_device *device, void rdma_lag_put_ah_roce_slave(struct net_device *xmit_slave) { - if (xmit_slave) - dev_put(xmit_slave); + dev_put(xmit_slave); } struct net_device *rdma_lag_get_ah_roce_slave(struct ib_device *device, diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c index 343288b02792..a5e88185171f 100644 --- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c @@ -1021,10 +1021,8 @@ static int pvrdma_pci_probe(struct pci_dev *pdev, pvrdma_free_irq(dev); pci_free_irq_vectors(pdev); err_free_cq_ring: - if (dev->netdev) { - dev_put(dev->netdev); - dev->netdev = NULL; - } + dev_put(dev->netdev); + dev->netdev = NULL; pvrdma_page_dir_cleanup(dev, &dev->cq_pdir); err_free_async_ring: pvrdma_page_dir_cleanup(dev, &dev->async_pdir); @@ -1064,10 +1062,8 @@ static void pvrdma_pci_remove(struct pci_dev *pdev) flush_workqueue(event_wq); - if (dev->netdev) { - dev_put(dev->netdev); - dev->netdev = NULL; - } + dev_put(dev->netdev); + dev->netdev = NULL; /* Unregister ib device */ ib_unregister_device(&dev->ib_dev); diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c index cf8b0822f5c8..967004ccad98 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c @@ -2005,8 +2005,7 @@ static void ipoib_ndo_uninit(struct net_device *dev) priv->wq = NULL; } - if (priv->parent) - dev_put(priv->parent); + dev_put(priv->parent); } static int ipoib_set_vf_link_state(struct net_device *dev, int vf, int link_state) > > diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c > index 87b8cd657fb3..4900a0848124 100644 > --- a/drivers/infiniband/core/nldev.c > +++ b/drivers/infiniband/core/nldev.c > @@ -371,8 +371,7 @@ static int fill_port_info(struct sk_buff *msg, > } > > out: > - if (netdev) > - dev_put(netdev); > + dev_put(netdev); > return ret; > } > > -- > 2.20.1.7.g153144c >