netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] can: ctucanfd: Fix an error handling path in ctucan_probe_common()
@ 2023-05-15 20:36 Christophe JAILLET
  2023-05-15 20:51 ` Marc Kleine-Budde
  0 siblings, 1 reply; 4+ messages in thread
From: Christophe JAILLET @ 2023-05-15 20:36 UTC (permalink / raw)
  To: Pavel Pisa, Ondrej Ille, Wolfgang Grandegger, Marc Kleine-Budde,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Martin Jerabek
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-can,
	netdev

If register_candev() fails, a previous netif_napi_add() needs to be undone.
Add the missing netif_napi_del() in the error handling path.

Fixes: 2dcb8e8782d8 ("can: ctucanfd: add support for CTU CAN FD open-source IP core - bus independent part.")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/net/can/ctucanfd/ctucanfd_base.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/can/ctucanfd/ctucanfd_base.c b/drivers/net/can/ctucanfd/ctucanfd_base.c
index 64c349fd4600..59e1708e43d6 100644
--- a/drivers/net/can/ctucanfd/ctucanfd_base.c
+++ b/drivers/net/can/ctucanfd/ctucanfd_base.c
@@ -1429,7 +1429,7 @@ int ctucan_probe_common(struct device *dev, void __iomem *addr, int irq, unsigne
 	ret = register_candev(ndev);
 	if (ret) {
 		dev_err(dev, "fail to register failed (err=%d)\n", ret);
-		goto err_deviceoff;
+		goto err_del_napi;
 	}
 
 	pm_runtime_put(dev);
@@ -1439,6 +1439,8 @@ int ctucan_probe_common(struct device *dev, void __iomem *addr, int irq, unsigne
 
 	return 0;
 
+err_del_napi:
+	netif_napi_del(&priv->napi);
 err_deviceoff:
 	pm_runtime_put(priv->dev);
 err_pmdisable:
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] can: ctucanfd: Fix an error handling path in ctucan_probe_common()
  2023-05-15 20:36 [PATCH] can: ctucanfd: Fix an error handling path in ctucan_probe_common() Christophe JAILLET
@ 2023-05-15 20:51 ` Marc Kleine-Budde
  2023-05-16 16:47   ` Christophe JAILLET
  0 siblings, 1 reply; 4+ messages in thread
From: Marc Kleine-Budde @ 2023-05-15 20:51 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Pavel Pisa, Ondrej Ille, Wolfgang Grandegger, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Martin Jerabek,
	linux-kernel, kernel-janitors, linux-can, netdev

[-- Attachment #1: Type: text/plain, Size: 625 bytes --]

On 15.05.2023 22:36:28, Christophe JAILLET wrote:
> If register_candev() fails, a previous netif_napi_add() needs to be undone.
> Add the missing netif_napi_del() in the error handling path.

What about this path:
free_candev(ndev) -> free_netdev() -> netif_napi_del()

| https://elixir.bootlin.com/linux/v6.3.2/source/net/core/dev.c#L10714

Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde          |
Embedded Linux                   | https://www.pengutronix.de |
Vertretung Nürnberg              | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-9   |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] can: ctucanfd: Fix an error handling path in ctucan_probe_common()
  2023-05-15 20:51 ` Marc Kleine-Budde
@ 2023-05-16 16:47   ` Christophe JAILLET
  2023-05-17  7:05     ` Marc Kleine-Budde
  0 siblings, 1 reply; 4+ messages in thread
From: Christophe JAILLET @ 2023-05-16 16:47 UTC (permalink / raw)
  To: Marc Kleine-Budde
  Cc: Pavel Pisa, Ondrej Ille, Wolfgang Grandegger, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Martin Jerabek,
	linux-kernel, kernel-janitors, linux-can, netdev

Le 15/05/2023 à 22:51, Marc Kleine-Budde a écrit :
> On 15.05.2023 22:36:28, Christophe JAILLET wrote:
>> If register_candev() fails, a previous netif_napi_add() needs to be undone.
>> Add the missing netif_napi_del() in the error handling path.
> 
> What about this path:
> free_candev(ndev) -> free_netdev() -> netif_napi_del()
> 
> | https://elixir.bootlin.com/linux/v6.3.2/source/net/core/dev.c#L10714
> 
> Marc
> 

Ok, thanks for the review,

so in fact this is the netif_napi_del() call in ctucan_platform_remove() 
that can be removed instead.

Harmless, but would be more consistent.
I'll send a patch for that.

CJ

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] can: ctucanfd: Fix an error handling path in ctucan_probe_common()
  2023-05-16 16:47   ` Christophe JAILLET
@ 2023-05-17  7:05     ` Marc Kleine-Budde
  0 siblings, 0 replies; 4+ messages in thread
From: Marc Kleine-Budde @ 2023-05-17  7:05 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Pavel Pisa, Ondrej Ille, Wolfgang Grandegger, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Martin Jerabek,
	linux-kernel, kernel-janitors, linux-can, netdev

[-- Attachment #1: Type: text/plain, Size: 1036 bytes --]

On 16.05.2023 18:47:17, Christophe JAILLET wrote:
> Le 15/05/2023 à 22:51, Marc Kleine-Budde a écrit :
> > On 15.05.2023 22:36:28, Christophe JAILLET wrote:
> > > If register_candev() fails, a previous netif_napi_add() needs to be undone.
> > > Add the missing netif_napi_del() in the error handling path.
> > 
> > What about this path:
> > free_candev(ndev) -> free_netdev() -> netif_napi_del()
> > 
> > | https://elixir.bootlin.com/linux/v6.3.2/source/net/core/dev.c#L10714
> > 
> > Marc
> > 
> 
> Ok, thanks for the review,
> 
> so in fact this is the netif_napi_del() call in ctucan_platform_remove()
> that can be removed instead.
> 
> Harmless, but would be more consistent.
> I'll send a patch for that.

Make it so!

regards,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde          |
Embedded Linux                   | https://www.pengutronix.de |
Vertretung Nürnberg              | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-9   |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-05-17  7:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-15 20:36 [PATCH] can: ctucanfd: Fix an error handling path in ctucan_probe_common() Christophe JAILLET
2023-05-15 20:51 ` Marc Kleine-Budde
2023-05-16 16:47   ` Christophe JAILLET
2023-05-17  7:05     ` Marc Kleine-Budde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).