Message ID | 3ab37c3934c99066a124f99e73c0fc077fcb69b4.1671607040.git.christophe.jaillet@wanadoo.fr |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp3385519wrn; Tue, 20 Dec 2022 23:30:39 -0800 (PST) X-Google-Smtp-Source: AMrXdXvLKjbkFnQh0bu6Y+aaGAtvo4s/95BlVc0ntXRe+unkzUxDbDyg1mETlLKWSRvqJDfCQt1C X-Received: by 2002:a62:6143:0:b0:577:3546:d7be with SMTP id v64-20020a626143000000b005773546d7bemr1363877pfb.30.1671607838864; Tue, 20 Dec 2022 23:30:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671607838; cv=none; d=google.com; s=arc-20160816; b=jxfRVTnqgTJYnH55itxka1ynprsuNUaBtI0F+Y3A0bXPatxOZFVVAT5Gryur/Qcvr+ 0Cc2SVCs07n5ynR+SlHbkaI+KZ/UJzHBYHDXiSPXaBUOgDoCrP0ThXwtXb5AUKrf3HUf uZcx4Vw/N+F7WzsVPwpSlt+zsmDwQAg6Oeqls56FJ/zf5VHUNsgvKdXkwuXwqausZOCa nY3iO5g6jxY/+5jOL+Ok/3ZT8faFE2cLuNfOYIoVRZiwUPT/jmS5rkp7bx1KuwPkpp8I jq8RCY4ItEEVY+gi8cmPbsxqfnAKLw73A9SqMZXNtGPDUUUA2s6qMf3cxMJRRaZFNpeH MqmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=yWPePZk71b3RnoRJu5WiSZVcpEfXwtzy+IvLxnWgRS0=; b=Ii+WM/CtJRFbUsD3XgM+CEKcK2IslRUm0SWj7Zmzsz2WdFHcG4pvh0SsLjn1871R+A SfLSX5aMse4hEPZz5oZIDRtbztwLO/geRJMpwNLtcU4We9yA4KO6Vmw17OH6bQjdMgsW w+o8vU/Y4kwVlC5iKea4XKI6Qh+jaJbOiR646LKS6MqDiWwzInfdY7NmKIwJLwOxFWhk Cr+06WgAWy2slKHyEsP2cf7gsUTUr0acdnwASPwXR0HVnSy4xYTbu03CeerXIFz2eXkp WMP+S2yYJf1x9Y7+XkVPL0EX8xMCY+oLvZe7Sq8Etwo2f5SgcL7mASFpWE5Zk6IwaYO/ xWaw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a20-20020aa794b4000000b00575deb1844asi14827504pfl.381.2022.12.20.23.30.26; Tue, 20 Dec 2022 23:30:38 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234102AbiLUHSK (ORCPT <rfc822;pacteraone@gmail.com> + 99 others); Wed, 21 Dec 2022 02:18:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234435AbiLUHSC (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 21 Dec 2022 02:18:02 -0500 Received: from smtp.smtpout.orange.fr (smtp-24.smtpout.orange.fr [80.12.242.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49A5C20BD3 for <linux-kernel@vger.kernel.org>; Tue, 20 Dec 2022 23:17:58 -0800 (PST) Received: from pop-os.home ([86.243.100.34]) by smtp.orange.fr with ESMTPA id 7tMQp7QGOyEjG7tMQpZrZE; Wed, 21 Dec 2022 08:17:57 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Wed, 21 Dec 2022 08:17:57 +0100 X-ME-IP: 86.243.100.34 From: Christophe JAILLET <christophe.jaillet@wanadoo.fr> To: Krzysztof Halasa <khalasa@piap.pl>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, =?utf-8?q?Krzysztof_Ha=C5=82asa?= <khc@pm.waw.pl> Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET <christophe.jaillet@wanadoo.fr>, netdev@vger.kernel.org Subject: [PATCH] ixp4xx_eth: Fix an error handling path in ixp4xx_eth_probe() Date: Wed, 21 Dec 2022 08:17:52 +0100 Message-Id: <3ab37c3934c99066a124f99e73c0fc077fcb69b4.1671607040.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=unavailable 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?1752807861343287376?= X-GMAIL-MSGID: =?utf-8?q?1752807861343287376?= |
Series |
ixp4xx_eth: Fix an error handling path in ixp4xx_eth_probe()
|
|
Commit Message
Christophe JAILLET
Dec. 21, 2022, 7:17 a.m. UTC
If an error occurs after a successful ixp4xx_mdio_register() call, it
should be undone by a corresponding ixp4xx_mdio_remove().
Add the missing call in the error handling path, as already done in the
remove function.
Fixes: 2098c18d6cf6 ("IXP4xx: Add PHYLIB support to Ethernet driver.")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/net/ethernet/xscale/ixp4xx_eth.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
Comments
On Wed, Dec 21, 2022 at 08:17:52AM +0100, Christophe JAILLET wrote: > If an error occurs after a successful ixp4xx_mdio_register() call, it > should be undone by a corresponding ixp4xx_mdio_remove(). What about error when mdio_bus is 0? It means that mdio_register can return no error, but sth happen and there is no need to call mdio_remove in this case? I mean: /* If the instance with the MDIO bus has not yet appeared, * defer probing until it gets probed. */ if (!mdio_bus) return -EPROBE_DEFER; > > Add the missing call in the error handling path, as already done in the > remove function. > > Fixes: 2098c18d6cf6 ("IXP4xx: Add PHYLIB support to Ethernet driver.") > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > --- > drivers/net/ethernet/xscale/ixp4xx_eth.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c > index 3b0c5f177447..007d68b385a5 100644 > --- a/drivers/net/ethernet/xscale/ixp4xx_eth.c > +++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c > @@ -1490,8 +1490,10 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) > > netif_napi_add_weight(ndev, &port->napi, eth_poll, NAPI_WEIGHT); netif_napi_add_weight() doesn't need to be unrolled in case of error (call netif_napi_del() or something)? Thanks > > - if (!(port->npe = npe_request(NPE_ID(port->id)))) > - return -EIO; > + if (!(port->npe = npe_request(NPE_ID(port->id)))) { > + err = -EIO; > + goto err_remove_mdio; > + } > > port->plat = plat; > npe_port_tab[NPE_ID(port->id)] = port; > @@ -1530,6 +1532,8 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) > err_free_mem: > npe_port_tab[NPE_ID(port->id)] = NULL; > npe_release(port->npe); > +err_remove_mdio: > + ixp4xx_mdio_remove(); > return err; > } > > -- > 2.34.1 >
On Wed, 21 Dec 2022 19:50:23 +0100 Michal Swiatkowski wrote: > On Wed, Dec 21, 2022 at 08:17:52AM +0100, Christophe JAILLET wrote: > > If an error occurs after a successful ixp4xx_mdio_register() call, it > > should be undone by a corresponding ixp4xx_mdio_remove(). > > What about error when mdio_bus is 0? It means that mdio_register can > return no error, but sth happen and there is no need to call mdio_remove > in this case? > > I mean: > /* If the instance with the MDIO bus has not yet appeared, > * defer probing until it gets probed. > */ > if (!mdio_bus) > return -EPROBE_DEFER; Indeed, I think a closer look is warranted, this code operates on global variables, it's also not clear to me whether it's safe to always call remove, even if has_mdio is false? > > Add the missing call in the error handling path, as already done in the > > remove function. > > > > Fixes: 2098c18d6cf6 ("IXP4xx: Add PHYLIB support to Ethernet driver.") > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > > --- > > drivers/net/ethernet/xscale/ixp4xx_eth.c | 8 ++++++-- > > 1 file changed, 6 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c > > index 3b0c5f177447..007d68b385a5 100644 > > --- a/drivers/net/ethernet/xscale/ixp4xx_eth.c > > +++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c > > @@ -1490,8 +1490,10 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) > > > > netif_napi_add_weight(ndev, &port->napi, eth_poll, NAPI_WEIGHT); > netif_napi_add_weight() doesn't need to be unrolled in case of error > (call netif_napi_del() or something)? free_netdev() cleans it up automatically
diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c index 3b0c5f177447..007d68b385a5 100644 --- a/drivers/net/ethernet/xscale/ixp4xx_eth.c +++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c @@ -1490,8 +1490,10 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) netif_napi_add_weight(ndev, &port->napi, eth_poll, NAPI_WEIGHT); - if (!(port->npe = npe_request(NPE_ID(port->id)))) - return -EIO; + if (!(port->npe = npe_request(NPE_ID(port->id)))) { + err = -EIO; + goto err_remove_mdio; + } port->plat = plat; npe_port_tab[NPE_ID(port->id)] = port; @@ -1530,6 +1532,8 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) err_free_mem: npe_port_tab[NPE_ID(port->id)] = NULL; npe_release(port->npe); +err_remove_mdio: + ixp4xx_mdio_remove(); return err; }