[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221024090256.717236-1-dzm91@hust.edu.cn>
Date: Mon, 24 Oct 2022 17:02:52 +0800
From: Dongliang Mu <dzm91@...t.edu.cn>
To: Wolfgang Grandegger <wg@...ndegger.com>,
Marc Kleine-Budde <mkl@...gutronix.de>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Vincent Mailhol <mailhol.vincent@...adoo.fr>,
Stefan Mätje <stefan.maetje@....eu>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Oliver Hartkopp <socketcan@...tkopp.net>,
Sebastian Würl <sebastian.wuerl@...ratech.com>,
Dongliang Mu <dzm91@...t.edu.cn>,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
Uwe Kleine-König
<u.kleine-koenig@...gutronix.de>,
Timo Schlüßler <schluessler@...use.de>
Cc: linux-can@...r.kernel.org, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH v2] can: mcp251x: fix error handling code in mcp251x_can_probe
In mcp251x_can_probe, if mcp251x_gpio_setup fails, it forgets to
unregister the can device.
Fix this by unregistering can device in mcp251x_can_probe.
Fixes: 2d52dabbef60 ("can: mcp251x: add GPIO support")
Signed-off-by: Dongliang Mu <dzm91@...t.edu.cn>
---
v1->v2: add fixes tag
drivers/net/can/spi/mcp251x.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/can/spi/mcp251x.c b/drivers/net/can/spi/mcp251x.c
index c320de474f40..00ed46683656 100644
--- a/drivers/net/can/spi/mcp251x.c
+++ b/drivers/net/can/spi/mcp251x.c
@@ -1415,11 +1415,14 @@ static int mcp251x_can_probe(struct spi_device *spi)
ret = mcp251x_gpio_setup(priv);
if (ret)
- goto error_probe;
+ goto err_reg_candev;
netdev_info(net, "MCP%x successfully initialized.\n", priv->model);
return 0;
+err_reg_candev:
+ unregister_candev(net);
+
error_probe:
destroy_workqueue(priv->wq);
priv->wq = NULL;
--
2.35.1
Powered by blists - more mailing lists