From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2308E24E4A1; Mon, 13 Apr 2026 16:39:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776098357; cv=none; b=svoobS6B+smEm96MkUw+AjdwD+Htb8bj5jA/VDFIBKnUCSh4QLIUVOgY9TGyOW7Sg7d/RzXxxoFeQy4cpln7MBLLSRJY4H6oPZFDH1Cdeqhq7QMjU+bSlSKTZpPUOiBtBoE+Qdq9tQ1vQV9Cdu4SH/2FmJAkij4otykPKoXAtcI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776098357; c=relaxed/simple; bh=5aL3sb9CnRRI88jbVrDnux/ohvlUMfVLm+yyaRoPka0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rwEACmXIiV5CqCnEMLbt3+RGNxU3zKl4mkQD4VjtP+ylsDiUdPeBa8BUXBcMZD9/ygbAPW70BT8wdTr6gMLFiMSHVS8DfVFAwxIjjuCM/DsMYfuXnOX6xrQB/C8Mphe/9hi0SvVet7QcqVESOeGgeX/aS/U69nRJm1xRAf4wbK8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=wf4tD5Jy; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="wf4tD5Jy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ACD9EC2BCAF; Mon, 13 Apr 2026 16:39:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1776098357; bh=5aL3sb9CnRRI88jbVrDnux/ohvlUMfVLm+yyaRoPka0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wf4tD5JynSjpw7FZM2S4IapJaLlbO+XES6TpdWNDUOIRyiqmpT2DMoK9Kd+RpiXld 6mZXOMlKtH1JTR2mIeUdQ/B2KxiJ7g6zfjva1t0qFJFIeWJ17UZ+MGHjXFBDbdpPDM KRYHtLQcxKlMJ3d+ifbmqL8/aReskfLO5Y1au6WM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jakub Kicinski , Marc Kleine-Budde , Ruohan Lan , Sasha Levin Subject: [PATCH 5.15 493/570] can: gs_usb: gs_usb_receive_bulk_callback(): unanchor URL on usb_submit_urb() error Date: Mon, 13 Apr 2026 18:00:24 +0200 Message-ID: <20260413155848.926110122@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260413155830.386096114@linuxfoundation.org> References: <20260413155830.386096114@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Marc Kleine-Budde [ Upstream commit 79a6d1bfe1148bc921b8d7f3371a7fbce44e30f7 ] In commit 7352e1d5932a ("can: gs_usb: gs_usb_receive_bulk_callback(): fix URB memory leak"), the URB was re-anchored before usb_submit_urb() in gs_usb_receive_bulk_callback() to prevent a leak of this URB during cleanup. However, this patch did not take into account that usb_submit_urb() could fail. The URB remains anchored and usb_kill_anchored_urbs(&parent->rx_submitted) in gs_can_close() loops infinitely since the anchor list never becomes empty. To fix the bug, unanchor the URB when an usb_submit_urb() error occurs, also print an info message. Fixes: 7352e1d5932a ("can: gs_usb: gs_usb_receive_bulk_callback(): fix URB memory leak") Reported-by: Jakub Kicinski Closes: https://lore.kernel.org/all/20260110223836.3890248-1-kuba@kernel.org/ Link: https://patch.msgid.link/20260116-can_usb-fix-reanchor-v1-1-9d74e7289225@pengutronix.de Signed-off-by: Marc Kleine-Budde Signed-off-by: Ruohan Lan Signed-off-by: Sasha Levin --- drivers/net/can/usb/gs_usb.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/can/usb/gs_usb.c b/drivers/net/can/usb/gs_usb.c index acffe11a0ae13..134f830508d9f 100644 --- a/drivers/net/can/usb/gs_usb.c +++ b/drivers/net/can/usb/gs_usb.c @@ -405,6 +405,10 @@ static void gs_usb_receive_bulk_callback(struct urb *urb) usb_anchor_urb(urb, &usbcan->rx_submitted); rc = usb_submit_urb(urb, GFP_ATOMIC); + if (!rc) + return; + + usb_unanchor_urb(urb); /* USB failure take down all interfaces */ if (rc == -ENODEV) { @@ -413,6 +417,9 @@ static void gs_usb_receive_bulk_callback(struct urb *urb) if (usbcan->canch[rc]) netif_device_detach(usbcan->canch[rc]->netdev); } + } else if (rc != -ESHUTDOWN && net_ratelimit()) { + netdev_info(netdev, "failed to re-submit IN URB: %pe\n", + ERR_PTR(urb->status)); } } -- 2.53.0