[PATCH] driver: net: can: delete napi if register_candev fails
From: Dongliang Mu
Date: Wed Oct 13 2021 - 00:04:49 EST
If register_candev fails, xcan_probe does not clean the napi
created by netif_napi_add.
Fix this by adding error handling code to clean napi when
register_candev fails.
Signed-off-by: Dongliang Mu <mudongliangabcd@xxxxxxxxx>
---
drivers/net/can/xilinx_can.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/can/xilinx_can.c b/drivers/net/can/xilinx_can.c
index 3b883e607d8b..6ee0b5a8cdfc 100644
--- a/drivers/net/can/xilinx_can.c
+++ b/drivers/net/can/xilinx_can.c
@@ -1807,7 +1807,7 @@ static int xcan_probe(struct platform_device *pdev)
ret = register_candev(ndev);
if (ret) {
dev_err(&pdev->dev, "fail to register failed (err=%d)\n", ret);
- goto err_disableclks;
+ goto err_del_napi;
}
devm_can_led_init(ndev);
@@ -1825,6 +1825,8 @@ static int xcan_probe(struct platform_device *pdev)
return 0;
+err_del_napi:
+ netif_napi_del(&priv->napi);
err_disableclks:
pm_runtime_put(priv->dev);
pm_runtime_disable(&pdev->dev);
--
2.25.1