Message ID | fde673f106d2b264ad76759195901aae94691b5c.1671569785.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 c7csp3177749wrn; Tue, 20 Dec 2022 13:00:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf5lHwX3BB5hUipsOnaPEeMrbH7hJsB6xIS4pQn02O782J1sE0RicPw0e96paSh6llhEhWGC X-Received: by 2002:a17:907:6d96:b0:7c1:7442:8b77 with SMTP id sb22-20020a1709076d9600b007c174428b77mr37657743ejc.5.1671570015304; Tue, 20 Dec 2022 13:00:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671570015; cv=none; d=google.com; s=arc-20160816; b=xIoECcUh0OHT7q2PKMm/d7/7JSBFNHS22CbzLROJMmDfZkVGg1ZKKJwX13J6HIwULJ paJasUa/Mjbx4w9km9M2teNHlpRXIIurggIx4ktl7YbK3TvtWjF1m4PRj9/mURQONIIS Gu9nVompsaPcPxs9IE44Ri5J82FAxKszuIJt5+9ceKL/h8PEyqrdtsXjIYHFjx6KSdXy S+WaZ3vWPHMqjtPlC8wAt8phjaaHVhFmPDMljHrYU7JsnDlsPPuc4rHKm1upk2JVszTT HKtjGsRfzuVxm3NNM5iApEC8JgKW1jdtdLX4/Jp4GqW7g4vWH0rFkdi7Gjw1OPkn0kco c95A== 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=L5o94Pkhs8E3vT6Y1sb4BP5bXhCoj/siC/LlkaDTSE8=; b=xDjRpxIXRSU5PkX4RlZXhEpjnIxcf6ifKcTB1rWYIEQXW4EiguP0Vd+6MEdDbl0Wzt iy9SIgQ2qPz1kibfYW3psEnPp8SKGLdTax1IvXZDb5Rq63rDmS/Lk4QZCa/bwb1LIL3M QxPOeKggjjO80WG4MTj3TqdTi+mrFMJBzvhd8g6PID3Qq9pSj53QF5MHD38tPmGQXIch JmYX1QX8MpWYN/Yhpe5HNRwtcPPmTnP8PtcVqu+LLYIx7fwFUslHBw3TjTZ1igVUj/bq 41lZuu31S4ucx5XVibL3PZhLMKa7CRg+A5ecZfeqM8eWju1p5Kx74UQRfBxfNrRqfrfl IF7A== 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 h9-20020a05640250c900b0045c97cb9027si13838794edb.421.2022.12.20.12.59.51; Tue, 20 Dec 2022 13:00:15 -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 S234331AbiLTU5U (ORCPT <rfc822;abdi.embedded@gmail.com> + 99 others); Tue, 20 Dec 2022 15:57:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234288AbiLTU5O (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 20 Dec 2022 15:57:14 -0500 Received: from smtp.smtpout.orange.fr (smtp-24.smtpout.orange.fr [80.12.242.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0AF2113DC8 for <linux-kernel@vger.kernel.org>; Tue, 20 Dec 2022 12:57:11 -0800 (PST) Received: from pop-os.home ([86.243.100.34]) by smtp.orange.fr with ESMTPA id 7jfgp6zGQPNsN7jfgpkyQP; Tue, 20 Dec 2022 21:57:09 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Tue, 20 Dec 2022 21:57:09 +0100 X-ME-IP: 86.243.100.34 From: Christophe JAILLET <christophe.jaillet@wanadoo.fr> To: "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Taku Izumi <izumi.taku@jp.fujitsu.com> Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET <christophe.jaillet@wanadoo.fr>, netdev@vger.kernel.org Subject: [PATCH net] fjes: Fix an error handling path in fjes_probe() Date: Tue, 20 Dec 2022 21:57:06 +0100 Message-Id: <fde673f106d2b264ad76759195901aae94691b5c.1671569785.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=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?1752768200636344193?= X-GMAIL-MSGID: =?utf-8?q?1752768200636344193?= |
Series |
[net] fjes: Fix an error handling path in fjes_probe()
|
|
Commit Message
Christophe JAILLET
Dec. 20, 2022, 8:57 p.m. UTC
A netif_napi_add() call is hidden in fjes_sw_init(). It should be undone
by a corresponding netif_napi_del() call in the error handling path of the
probe, as already done inthe remove function.
Fixes: 265859309a76 ("fjes: NAPI polling function")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/net/fjes/fjes_main.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
Comments
On Tue, Dec 20, 2022 at 09:57:06PM +0100, Christophe JAILLET wrote: > A netif_napi_add() call is hidden in fjes_sw_init(). It should be undone > by a corresponding netif_napi_del() call in the error handling path of the > probe, as already done inthe remove function. > > Fixes: 265859309a76 ("fjes: NAPI polling function") > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > --- > drivers/net/fjes/fjes_main.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/fjes/fjes_main.c b/drivers/net/fjes/fjes_main.c > index 2513be6d4e11..01b4c9c6adbd 100644 > --- a/drivers/net/fjes/fjes_main.c > +++ b/drivers/net/fjes/fjes_main.c > @@ -1370,7 +1370,7 @@ static int fjes_probe(struct platform_device *plat_dev) > adapter->txrx_wq = alloc_workqueue(DRV_NAME "/txrx", WQ_MEM_RECLAIM, 0); > if (unlikely(!adapter->txrx_wq)) { > err = -ENOMEM; > - goto err_free_netdev; > + goto err_del_napi; > } > > adapter->control_wq = alloc_workqueue(DRV_NAME "/control", > @@ -1431,6 +1431,8 @@ static int fjes_probe(struct platform_device *plat_dev) > destroy_workqueue(adapter->control_wq); > err_free_txrx_wq: > destroy_workqueue(adapter->txrx_wq); > +err_del_napi: > + netif_napi_del(&adapter->napi); > err_free_netdev: > free_netdev(netdev); > err_out: Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com> I wonder if it won't be better to have fjes_sw_deinit() instead or change fjes_sw_init to only netif_napi_add(). You know, to avoid another bug here when someone add sth to the fjes_sw_deinit(). This is only suggestion, patch looks fine. > -- > 2.34.1 >
On Tue, 20 Dec 2022 21:57:06 +0100 Christophe JAILLET wrote: > A netif_napi_add() call is hidden in fjes_sw_init(). It should be undone > by a corresponding netif_napi_del() call in the error handling path of the > probe, as already done inthe remove function. Ah, now I see why Michal asked about netif_napi_del() in the other driver :S free_netdev() cleans up NAPIs.
Le 21/12/2022 à 10:59, Michal Swiatkowski a écrit : > On Tue, Dec 20, 2022 at 09:57:06PM +0100, Christophe JAILLET wrote: >> A netif_napi_add() call is hidden in fjes_sw_init(). It should be undone >> by a corresponding netif_napi_del() call in the error handling path of the >> probe, as already done inthe remove function. >> >> Fixes: 265859309a76 ("fjes: NAPI polling function") >> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> >> --- >> drivers/net/fjes/fjes_main.c | 4 +++- >> 1 file changed, 3 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/net/fjes/fjes_main.c b/drivers/net/fjes/fjes_main.c >> index 2513be6d4e11..01b4c9c6adbd 100644 >> --- a/drivers/net/fjes/fjes_main.c >> +++ b/drivers/net/fjes/fjes_main.c >> @@ -1370,7 +1370,7 @@ static int fjes_probe(struct platform_device *plat_dev) >> adapter->txrx_wq = alloc_workqueue(DRV_NAME "/txrx", WQ_MEM_RECLAIM, 0); >> if (unlikely(!adapter->txrx_wq)) { >> err = -ENOMEM; >> - goto err_free_netdev; >> + goto err_del_napi; >> } >> >> adapter->control_wq = alloc_workqueue(DRV_NAME "/control", >> @@ -1431,6 +1431,8 @@ static int fjes_probe(struct platform_device *plat_dev) >> destroy_workqueue(adapter->control_wq); >> err_free_txrx_wq: >> destroy_workqueue(adapter->txrx_wq); >> +err_del_napi: >> + netif_napi_del(&adapter->napi); >> err_free_netdev: >> free_netdev(netdev); >> err_out: > > Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com> > > I wonder if it won't be better to have fjes_sw_deinit() instead or > change fjes_sw_init to only netif_napi_add(). You know, to avoid another > bug here when someone add sth to the fjes_sw_deinit(). This is only > suggestion, patch looks fine. hi, based on Jakub's comment [1], free_netdev() already cleans up NAPIs (see [2]). So would it make more sense to remove netif_napi_del() from the .remove() function instead? The call looks useless to me now. CJ [1]: https://lore.kernel.org/all/20221221174043.1191996a@kernel.org/ [2]: https://elixir.bootlin.com/linux/v6.2-rc1/source/net/core/dev.c#L10710 > >> -- >> 2.34.1 >> >
On Thu, Dec 29, 2022 at 05:34:22PM +0100, Christophe JAILLET wrote: > Le 21/12/2022 à 10:59, Michal Swiatkowski a écrit : > > On Tue, Dec 20, 2022 at 09:57:06PM +0100, Christophe JAILLET wrote: > > > A netif_napi_add() call is hidden in fjes_sw_init(). It should be undone > > > by a corresponding netif_napi_del() call in the error handling path of the > > > probe, as already done inthe remove function. > > > > > > Fixes: 265859309a76 ("fjes: NAPI polling function") > > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > > > --- > > > drivers/net/fjes/fjes_main.c | 4 +++- > > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/net/fjes/fjes_main.c b/drivers/net/fjes/fjes_main.c > > > index 2513be6d4e11..01b4c9c6adbd 100644 > > > --- a/drivers/net/fjes/fjes_main.c > > > +++ b/drivers/net/fjes/fjes_main.c > > > @@ -1370,7 +1370,7 @@ static int fjes_probe(struct platform_device *plat_dev) > > > adapter->txrx_wq = alloc_workqueue(DRV_NAME "/txrx", WQ_MEM_RECLAIM, 0); > > > if (unlikely(!adapter->txrx_wq)) { > > > err = -ENOMEM; > > > - goto err_free_netdev; > > > + goto err_del_napi; > > > } > > > adapter->control_wq = alloc_workqueue(DRV_NAME "/control", > > > @@ -1431,6 +1431,8 @@ static int fjes_probe(struct platform_device *plat_dev) > > > destroy_workqueue(adapter->control_wq); > > > err_free_txrx_wq: > > > destroy_workqueue(adapter->txrx_wq); > > > +err_del_napi: > > > + netif_napi_del(&adapter->napi); > > > err_free_netdev: > > > free_netdev(netdev); > > > err_out: > > > > Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com> > > > > I wonder if it won't be better to have fjes_sw_deinit() instead or > > change fjes_sw_init to only netif_napi_add(). You know, to avoid another > > bug here when someone add sth to the fjes_sw_deinit(). This is only > > suggestion, patch looks fine. > > hi, > > based on Jakub's comment [1], free_netdev() already cleans up NAPIs (see > [2]). > > So would it make more sense to remove netif_napi_del() from the .remove() > function instead? > The call looks useless to me now. > > CJ > > [1]: https://lore.kernel.org/all/20221221174043.1191996a@kernel.org/ > [2]: https://elixir.bootlin.com/linux/v6.2-rc1/source/net/core/dev.c#L10710 > Yeah, it make more sense. Thanks, Michal > > > > > -- > > > 2.34.1 > > > > > >
diff --git a/drivers/net/fjes/fjes_main.c b/drivers/net/fjes/fjes_main.c index 2513be6d4e11..01b4c9c6adbd 100644 --- a/drivers/net/fjes/fjes_main.c +++ b/drivers/net/fjes/fjes_main.c @@ -1370,7 +1370,7 @@ static int fjes_probe(struct platform_device *plat_dev) adapter->txrx_wq = alloc_workqueue(DRV_NAME "/txrx", WQ_MEM_RECLAIM, 0); if (unlikely(!adapter->txrx_wq)) { err = -ENOMEM; - goto err_free_netdev; + goto err_del_napi; } adapter->control_wq = alloc_workqueue(DRV_NAME "/control", @@ -1431,6 +1431,8 @@ static int fjes_probe(struct platform_device *plat_dev) destroy_workqueue(adapter->control_wq); err_free_txrx_wq: destroy_workqueue(adapter->txrx_wq); +err_del_napi: + netif_napi_del(&adapter->napi); err_free_netdev: free_netdev(netdev); err_out: