linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, kuba@kernel.org, linux-can@vger.kernel.org,
	kernel@pengutronix.de, Zhang Qilong <zhangqilong3@huawei.com>,
	Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>,
	Marc Kleine-Budde <mkl@pengutronix.de>
Subject: [net 1/3] can: softing: softing_netdev_open(): fix error handling
Date: Fri,  4 Dec 2020 14:35:06 +0100	[thread overview]
Message-ID: <20201204133508.742120-2-mkl@pengutronix.de> (raw)
In-Reply-To: <20201204133508.742120-1-mkl@pengutronix.de>

From: Zhang Qilong <zhangqilong3@huawei.com>

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>
---
 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 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;
 }
 

base-commit: bbe2ba04c5a92a49db8a42c850a5a2f6481e47eb
-- 
2.29.2



  reply	other threads:[~2020-12-04 13:36 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-04 13:35 pull-request: can 2020-12-04 Marc Kleine-Budde
2020-12-04 13:35 ` Marc Kleine-Budde [this message]
2020-12-04 13:35 ` [net 2/3] can: isotp: isotp_setsockopt(): block setsockopt on bound sockets Marc Kleine-Budde
2020-12-04 13:35 ` [net 3/3] can: isotp: add SF_BROADCAST support for functional addressing Marc Kleine-Budde
2020-12-05  3:44   ` Jakub Kicinski
2020-12-05 11:26     ` Oliver Hartkopp
2020-12-05 20:24       ` Marc Kleine-Budde
2020-12-05 20:33         ` Jakub Kicinski
2020-12-05 20:56           ` Marc Kleine-Budde
2020-12-05 21:09             ` Jakub Kicinski
2020-12-05 21:20               ` Marc Kleine-Budde
2020-12-08 12:54               ` Oliver Hartkopp
2020-12-08 18:07                 ` Jakub Kicinski
2020-12-09  7:45                   ` Marc Kleine-Budde
2020-12-10  8:18                     ` Oliver Hartkopp
2020-12-10  9:55                       ` Marc Kleine-Budde

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201204133508.742120-2-mkl@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=davem@davemloft.net \
    --cc=dev.kurt@vandijck-laurijssen.be \
    --cc=kernel@pengutronix.de \
    --cc=kuba@kernel.org \
    --cc=linux-can@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=zhangqilong3@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).