diff options
author | Zhang Qilong <zhangqilong3@huawei.com> | 2020-12-04 16:35:06 +0300 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2020-12-06 00:08:11 +0300 |
commit | 4d1be581ec6b92a338bb7ed23e1381f45ddf336f (patch) | |
tree | ae785fa14e5135aec7ed2fc9f6c5b00bb736960d /drivers/net/can/softing | |
parent | a54ba3465d86fa5dd7d41bb88c0b5e71fb3b627e (diff) | |
download | linux-4d1be581ec6b92a338bb7ed23e1381f45ddf336f.tar.xz |
can: softing: softing_netdev_open(): fix error handling
If softing_netdev_open() fails, we should call close_candev() to avoid
reference leak.
Fixes: 03fd3cf5a179d ("can: add driver for Softing card")
Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
Acked-by: Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>
Link: https://lore.kernel.org/r/20201202151632.1343786-1-zhangqilong3@huawei.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Link: https://lore.kernel.org/r/20201204133508.742120-2-mkl@pengutronix.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'drivers/net/can/softing')
-rw-r--r-- | drivers/net/can/softing/softing_main.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/net/can/softing/softing_main.c b/drivers/net/can/softing/softing_main.c index 9d2faaa39ce4..c9ca8b9fceb9 100644 --- a/drivers/net/can/softing/softing_main.c +++ b/drivers/net/can/softing/softing_main.c @@ -382,8 +382,13 @@ static int softing_netdev_open(struct net_device *ndev) /* check or determine and set bittime */ ret = open_candev(ndev); - if (!ret) - ret = softing_startstop(ndev, 1); + if (ret) + return ret; + + ret = softing_startstop(ndev, 1); + if (ret < 0) + close_candev(ndev); + return ret; } |