Message ID | 1669258989-18277-1-git-send-email-zhangchangzhong@huawei.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3162947wrr; Wed, 23 Nov 2022 19:14:17 -0800 (PST) X-Google-Smtp-Source: AA0mqf5bsTJKlndj4+pqlAkHen+Ts3rPId9IK/byBZw3h27njWf7OfeDJmq/4zpM8iwaCtxRv6RP X-Received: by 2002:a17:906:e083:b0:78d:c155:56b2 with SMTP id gh3-20020a170906e08300b0078dc15556b2mr17520398ejb.291.1669259657530; Wed, 23 Nov 2022 19:14:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669259657; cv=none; d=google.com; s=arc-20160816; b=h5lX3wkMwCiazdOfQkZwT0GbmFCxdIBIaEm1DEqmkoWesKIME/RNz7uRur67s1Nxrf 2WDjo/bB5oUadeawXDc3gxQVkXYNtooWsYSyCB+Rv4H4KBy7BPiDXPchk4f3La0ygx2Z y6k7njbJ0CSLOu00mC5iVegiwbl78Ynau12YZFOR7NQG+1Pzuhn6JiXLnE6Nb5VJNzXK pbYEIFfT/3X7TpihtxZsGwMNQ5mNrNb0uM4jGdaOaNYz/fRVPlXYPDhLT2EDB0DhlbxN s8UCKzfSOis1nxq9Y2kT9YwTlrEZVO3xpBdNpX3MYKb0/h++ox7J6jRg3q8nYttoi8oS CT6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=sXLiPXVhMePcF2yoN72zTAmqjXs2k++LAnvkINVum9k=; b=qO27suZZpn7PUm3YulXw7IgIEf3O60elgGqSfpg+PfJSC4k23//uzDJrOTj6QsuAu5 BHkT84DiQ6Tt+eQHcLK+ilAOZ04U3DDmbff8/M2+tqaiIzqghPtX2VVNV+5+aQWIqJMk OwBEfXCg9xlZSOVpi2w9J2NYvi300EpItZbIZD0jjy0ng9PI4e0M/xMV5ZEFbeeBT9q8 RGjR7EQqdC42rAs/Mv4lq43N5hJ9WXrSmlHWg6gNfiI8jIfrjtbOJOYJpj22eL3LC0Ui RHtLWM+Y8uYVSn00iVsCS0QTStMdN9ycb/KgnuqJehpi8F533O8Sp3nr238qDAKILajr B/dQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cw4-20020a170906478400b007919c624eadsi16488343ejc.522.2022.11.23.19.13.54; Wed, 23 Nov 2022 19:14:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229773AbiKXCnq (ORCPT <rfc822;fengqi706@gmail.com> + 99 others); Wed, 23 Nov 2022 21:43:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229507AbiKXCno (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 23 Nov 2022 21:43:44 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC8127A354; Wed, 23 Nov 2022 18:43:43 -0800 (PST) Received: from dggpeml500023.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4NHj093YNpzJnrb; Thu, 24 Nov 2022 10:40:25 +0800 (CST) Received: from dggpeml500006.china.huawei.com (7.185.36.76) by dggpeml500023.china.huawei.com (7.185.36.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 24 Nov 2022 10:43:42 +0800 Received: from localhost.localdomain (10.175.112.70) by dggpeml500006.china.huawei.com (7.185.36.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 24 Nov 2022 10:43:41 +0800 From: Zhang Changzhong <zhangchangzhong@huawei.com> To: "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Grygorii Strashko <grygorii.strashko@ti.com>, "Jesse Brandeburg" <jesse.brandeburg@intel.com> CC: Zhang Changzhong <zhangchangzhong@huawei.com>, <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org> Subject: [PATCH net] net: ethernet: ti: am65-cpsw: fix error handling in am65_cpsw_nuss_probe() Date: Thu, 24 Nov 2022 11:03:08 +0800 Message-ID: <1669258989-18277-1-git-send-email-zhangchangzhong@huawei.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.112.70] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpeml500006.china.huawei.com (7.185.36.76) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750345614440305917?= X-GMAIL-MSGID: =?utf-8?q?1750345614440305917?= |
Series |
[net] net: ethernet: ti: am65-cpsw: fix error handling in am65_cpsw_nuss_probe()
|
|
Commit Message
Zhang Changzhong
Nov. 24, 2022, 3:03 a.m. UTC
The am65_cpsw_nuss_cleanup_ndev() function calls unregister_netdev()
even if register_netdev() fails, which triggers WARN_ON(1) in
unregister_netdevice_many(). To fix it, make sure that
unregister_netdev() is called only on registered netdev.
Compile tested only.
Fixes: 84b4aa493249 ("net: ethernet: ti: am65-cpsw: add multi port support in mac-only mode")
Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com>
---
drivers/net/ethernet/ti/am65-cpsw-nuss.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Thu, Nov 24, 2022 at 11:03:08AM +0800, Zhang Changzhong wrote: > The am65_cpsw_nuss_cleanup_ndev() function calls unregister_netdev() > even if register_netdev() fails, which triggers WARN_ON(1) in If this has been only compile tested then I assume you haven't encounter this WARN_ON(1) trigger by yourself? > unregister_netdevice_many(). To fix it, make sure that > unregister_netdev() is called only on registered netdev. > > Compile tested only. > > Fixes: 84b4aa493249 ("net: ethernet: ti: am65-cpsw: add multi port support in mac-only mode") > Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com> > --- > drivers/net/ethernet/ti/am65-cpsw-nuss.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c > index c50b137..d04a239 100644 > --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c > +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c > @@ -2082,7 +2082,7 @@ static void am65_cpsw_nuss_cleanup_ndev(struct am65_cpsw_common *common) > > for (i = 0; i < common->port_num; i++) { > port = &common->ports[i]; > - if (port->ndev) > + if (port->ndev && port->ndev->reg_state == NETREG_REGISTERED) > unregister_netdev(port->ndev); It seems that if am65_cpsw_nuss_register_ndevs() fails on register_netdev() port->ndev is still a valid pointer, so your assumption looks correct to me. Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com> > } > } > -- > 2.9.5 >
Hello: This patch was applied to netdev/net.git (master) by David S. Miller <davem@davemloft.net>: On Thu, 24 Nov 2022 11:03:08 +0800 you wrote: > The am65_cpsw_nuss_cleanup_ndev() function calls unregister_netdev() > even if register_netdev() fails, which triggers WARN_ON(1) in > unregister_netdevice_many(). To fix it, make sure that > unregister_netdev() is called only on registered netdev. > > Compile tested only. > > [...] Here is the summary with links: - [net] net: ethernet: ti: am65-cpsw: fix error handling in am65_cpsw_nuss_probe() https://git.kernel.org/netdev/net/c/46fb6512538d You are awesome, thank you!
diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c index c50b137..d04a239 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c @@ -2082,7 +2082,7 @@ static void am65_cpsw_nuss_cleanup_ndev(struct am65_cpsw_common *common) for (i = 0; i < common->port_num; i++) { port = &common->ports[i]; - if (port->ndev) + if (port->ndev && port->ndev->reg_state == NETREG_REGISTERED) unregister_netdev(port->ndev); } }