summaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorZhang Qilong <zhangqilong3@huawei.com>2020-12-04 14:35:06 +0100
committerJakub Kicinski <kuba@kernel.org>2020-12-05 13:08:11 -0800
commit4d1be581ec6b92a338bb7ed23e1381f45ddf336f (patch)
treeae785fa14e5135aec7ed2fc9f6c5b00bb736960d /drivers/net
parenta54ba3465d86fa5dd7d41bb88c0b5e71fb3b627e (diff)
downloadlinux-4d1be581ec6b92a338bb7ed23e1381f45ddf336f.tar.bz2
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')
-rw-r--r--drivers/net/can/softing/softing_main.c9
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;
}