From: Szymon Wilczek <swilczek.lx@gmail.com>
To: mailhol@kernel.org, mkl@pengutronix.de
Cc: arunachalam.santhanam@in.bosch.com, linux-can@vger.kernel.org,
linux-kernel@vger.kernel.org,
Szymon Wilczek <swilczek.lx@gmail.com>,
syzbot+e8cb6691a7cf68256cb8@syzkaller.appspotmail.com
Subject: [PATCH] can: etas_es58x: fix memory leak in es58x_open()
Date: Mon, 22 Dec 2025 16:42:08 +0100 [thread overview]
Message-ID: <20251222154208.22117-1-swilczek.lx@gmail.com> (raw)
When es58x_alloc_rx_urbs() fails partway through allocating RX URBs
(e.g., if usb_submit_urb() fails at iteration i), the function returns
an error but leaves any previously allocated and anchored URBs leaked.
The issue is that es58x_open() returns directly on es58x_alloc_rx_urbs()
failure instead of jumping to the free_urbs label, which would call
es58x_free_urbs() to clean up any anchored URBs.
Fix this by changing 'return ret' to 'goto free_urbs' to ensure proper
cleanup of all allocated URBs on failure.
Fixes: 8537257874e9 ("can: etas_es58x: add core support for ETAS ES58X CAN USB interfaces")
Reported-by: syzbot+e8cb6691a7cf68256cb8@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=e8cb6691a7cf68256cb8
Signed-off-by: Szymon Wilczek <swilczek.lx@gmail.com>
---
drivers/net/can/usb/etas_es58x/es58x_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/can/usb/etas_es58x/es58x_core.c b/drivers/net/can/usb/etas_es58x/es58x_core.c
index f799233c2b72..d92c37f277d5 100644
--- a/drivers/net/can/usb/etas_es58x/es58x_core.c
+++ b/drivers/net/can/usb/etas_es58x/es58x_core.c
@@ -1784,7 +1784,7 @@ static int es58x_open(struct net_device *netdev)
if (!es58x_dev->opened_channel_cnt) {
ret = es58x_alloc_rx_urbs(es58x_dev);
if (ret)
- return ret;
+ goto free_urbs;
ret = es58x_set_realtime_diff_ns(es58x_dev);
if (ret)
--
2.52.0
next reply other threads:[~2025-12-22 15:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-22 15:42 Szymon Wilczek [this message]
2025-12-22 19:07 ` Vincent Mailhol
2025-12-23 1:17 ` [PATCH v2] can: etas_es58x: allow partial RX URB allocation to succeed Szymon Wilczek
2025-12-23 20:15 ` Vincent Mailhol
2025-12-24 12:02 ` 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=20251222154208.22117-1-swilczek.lx@gmail.com \
--to=swilczek.lx@gmail.com \
--cc=arunachalam.santhanam@in.bosch.com \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mailhol@kernel.org \
--cc=mkl@pengutronix.de \
--cc=syzbot+e8cb6691a7cf68256cb8@syzkaller.appspotmail.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
all inboxes | Powered by JetHome®