diff options
author | Dongliang Mu <dzm91@hust.edu.cn> | 2022-10-24 12:02:52 +0300 |
---|---|---|
committer | Marc Kleine-Budde <mkl@pengutronix.de> | 2022-10-25 10:13:14 +0300 |
commit | b1a09b63684cea56774786ca14c13b7041ffee63 (patch) | |
tree | 062060e5294d06c7faabee844f634360cddea5ae | |
parent | 3e5b3418827cefb5e1cc658806f02965791b8f07 (diff) | |
download | linux-b1a09b63684cea56774786ca14c13b7041ffee63.tar.xz |
can: mcp251x: mcp251x_can_probe(): add missing unregister_candev() in error path
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@hust.edu.cn>
Link: https://lore.kernel.org/all/20221024090256.717236-1-dzm91@hust.edu.cn
[mkl: adjust label]
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
-rw-r--r-- | drivers/net/can/spi/mcp251x.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/net/can/spi/mcp251x.c b/drivers/net/can/spi/mcp251x.c index c320de474f40..24883a65ca66 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 out_unregister_candev; netdev_info(net, "MCP%x successfully initialized.\n", priv->model); return 0; +out_unregister_candev: + unregister_candev(net); + error_probe: destroy_workqueue(priv->wq); priv->wq = NULL; |