diff mbox series

can: ctucanfd: Fix an error handling path in ctucan_probe_common()

Message ID 4b78c848826fde1b8a3ccd53f32b80674812cb12.1684182962.git.christophe.jaillet@wanadoo.fr (mailing list archive)
State Awaiting Upstream
Delegated to: Netdev Maintainers
Headers show
Series can: ctucanfd: Fix an error handling path in ctucan_probe_common() | expand

Checks

Context Check Description
netdev/tree_selection success Series ignored based on subject

Commit Message

Christophe JAILLET May 15, 2023, 8:36 p.m. UTC
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(-)

Comments

Marc Kleine-Budde May 15, 2023, 8:51 p.m. UTC | #1
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
Christophe JAILLET May 16, 2023, 4:47 p.m. UTC | #2
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
Marc Kleine-Budde May 17, 2023, 7:05 a.m. UTC | #3
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
diff mbox series

Patch

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: