* [PATCH] can: Fix error handling in softing_netdev_open
@ 2020-12-02 15:16 Zhang Qilong
2020-12-02 20:21 ` Kurt Van Dijck
2020-12-03 9:23 ` Marc Kleine-Budde
0 siblings, 2 replies; 3+ messages in thread
From: Zhang Qilong @ 2020-12-02 15:16 UTC (permalink / raw)
To: wg, mkl, davem, kuba; +Cc: linux-can
If softing_netdev_open failed, 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>
---
drivers/net/can/softing/softing_main.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/net/can/softing/softing_main.c b/drivers/net/can/softing/softing_main.c
index 03a68bb486fd..40070c930202 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;
}
--
2.25.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] can: Fix error handling in softing_netdev_open
2020-12-02 15:16 [PATCH] can: Fix error handling in softing_netdev_open Zhang Qilong
@ 2020-12-02 20:21 ` Kurt Van Dijck
2020-12-03 9:23 ` Marc Kleine-Budde
1 sibling, 0 replies; 3+ messages in thread
From: Kurt Van Dijck @ 2020-12-02 20:21 UTC (permalink / raw)
To: Zhang Qilong; +Cc: wg, mkl, davem, kuba, linux-can
Acked-by: Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>
On Wed, 02 Dec 2020 23:16:32 +0800, Zhang Qilong wrote:
>
> If softing_netdev_open failed, 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>
> ---
> drivers/net/can/softing/softing_main.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/can/softing/softing_main.c b/drivers/net/can/softing/softing_main.c
> index 03a68bb486fd..40070c930202 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;
> }
>
> --
> 2.25.4
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] can: Fix error handling in softing_netdev_open
2020-12-02 15:16 [PATCH] can: Fix error handling in softing_netdev_open Zhang Qilong
2020-12-02 20:21 ` Kurt Van Dijck
@ 2020-12-03 9:23 ` Marc Kleine-Budde
1 sibling, 0 replies; 3+ messages in thread
From: Marc Kleine-Budde @ 2020-12-03 9:23 UTC (permalink / raw)
To: Zhang Qilong, wg, davem, kuba; +Cc: linux-can
[-- Attachment #1.1: Type: text/plain, Size: 571 bytes --]
On 12/2/20 4:16 PM, Zhang Qilong wrote:
> If softing_netdev_open failed, 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>
Added to linux-can/testing.
Tnx,
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung West/Dortmund | Phone: +49-231-2826-924 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-12-03 9:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-02 15:16 [PATCH] can: Fix error handling in softing_netdev_open Zhang Qilong
2020-12-02 20:21 ` Kurt Van Dijck
2020-12-03 9:23 ` Marc Kleine-Budde
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.