Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp8289649rwb; Wed, 23 Nov 2022 19:15:27 -0800 (PST) X-Google-Smtp-Source: AA0mqf5QL/JDYD0u5oIJTuwJZVVt+CCvqQ2Hxoh8WkcUrC2BDubYEwsKPuQAo0W61AX4/G+popNb X-Received: by 2002:a17:906:6782:b0:7ad:7d50:dec2 with SMTP id q2-20020a170906678200b007ad7d50dec2mr27498646ejp.37.1669259727259; Wed, 23 Nov 2022 19:15:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669259727; cv=none; d=google.com; s=arc-20160816; b=lIsjmut8hyFF2Rx4A3zH91eHnQe54GLRCndp5qw3KiC/G2mFwqOPpE8AKqddqyOo1f A2KwDhQ/MIQO73gedbN4dPqCIFQsI/f0mC7kJ83hGPHsL3VDEz6MGuEAmzezfl3N7tCS ppMGUOJAorUaVodJC60yYHupMLjexSVXccSU1fr+gKGhs4CYjrYrGsr8O1X61Bgdom5J gMpvs9W3C1MbXcl5vPiB7meTUJy80w6RaaXV//3cGcSvFRYte7+Jp+EsrZCSAnkCHCk4 Zb2kSvpsgNX5ABrYz+8ptEr/e+GBlNCLnWhRCeOxAOQPToLe9mOq1RV4+CpcdYIJFG+Z E2dA== 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 Return-Path: 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.15.06; Wed, 23 Nov 2022 19:15:27 -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 + 88 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 ); 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 To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Grygorii Strashko , "Jesse Brandeburg" CC: Zhang Changzhong , , 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: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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); } } -- 2.9.5