From: Ruohan Lan <ruohanlan@aliyun.com>
To: gregkh@linuxfoundation.org, stable@vger.kernel.org
Cc: mkl@pengutronix.de, linux-can@vger.kernel.org,
Ruohan Lan <ruohanlan@aliyun.com>
Subject: [PATCH 5.15.y v2 1/3] can: gs_usb: gs_usb_receive_bulk_callback(): fix URB memory leak
Date: Fri, 3 Apr 2026 09:36:13 +0800 [thread overview]
Message-ID: <20260403013615.4641-2-ruohanlan@aliyun.com> (raw)
In-Reply-To: <20260403013615.4641-1-ruohanlan@aliyun.com>
From: Marc Kleine-Budde <mkl@pengutronix.de>
[ Upstream commit 7352e1d5932a0e777e39fa4b619801191f57e603 ]
In gs_can_open(), the URBs for USB-in transfers are allocated, added to the
parent->rx_submitted anchor and submitted. In the complete callback
gs_usb_receive_bulk_callback(), the URB is processed and resubmitted. In
gs_can_close() the URBs are freed by calling
usb_kill_anchored_urbs(parent->rx_submitted).
However, this does not take into account that the USB framework unanchors
the URB before the complete function is called. This means that once an
in-URB has been completed, it is no longer anchored and is ultimately not
released in gs_can_close().
Fix the memory leak by anchoring the URB in the
gs_usb_receive_bulk_callback() to the parent->rx_submitted anchor.
Fixes: d08e973a77d1 ("can: gs_usb: Added support for the GS_USB CAN devices")
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20260105-gs_usb-fix-memory-leak-v2-1-cc6ed6438034@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
[ The variable usbcan was renamed to parent in
commit b6980ad3a90c ("can: gs_usb: uniformly use "parent" as variable name for struct gs_usb")
introduced in v6.6. To backport to v5.15, replace parent with usbcan. ]
Signed-off-by: Ruohan Lan <ruohanlan@aliyun.com>
---
drivers/net/can/usb/gs_usb.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/can/usb/gs_usb.c b/drivers/net/can/usb/gs_usb.c
index ffa2a4d92d01..acffe11a0ae1 100644
--- a/drivers/net/can/usb/gs_usb.c
+++ b/drivers/net/can/usb/gs_usb.c
@@ -402,6 +402,8 @@ static void gs_usb_receive_bulk_callback(struct urb *urb)
usbcan
);
+ usb_anchor_urb(urb, &usbcan->rx_submitted);
+
rc = usb_submit_urb(urb, GFP_ATOMIC);
/* USB failure take down all interfaces */
--
2.43.0
next prev parent reply other threads:[~2026-04-03 1:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-03 1:36 [PATCH 5.15.y v2 0/3] Backport to fix CVE-2026-23031 in 5.15 Ruohan Lan
2026-04-03 1:36 ` Ruohan Lan [this message]
2026-04-03 1:36 ` [PATCH 5.15.y v2 2/3] can: gs_usb: gs_usb_receive_bulk_callback(): unanchor URL on usb_submit_urb() error Ruohan Lan
2026-04-03 1:36 ` [PATCH 5.15.y v2 3/3] can: gs_usb: gs_usb_receive_bulk_callback(): fix error message Ruohan Lan
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=20260403013615.4641-2-ruohanlan@aliyun.com \
--to=ruohanlan@aliyun.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-can@vger.kernel.org \
--cc=mkl@pengutronix.de \
--cc=stable@vger.kernel.org \
/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