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 A1FA12FB983; Wed, 28 Jan 2026 15:38:47 +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=1769614727; cv=none; b=Q+SvbiaigMBHH8hD3BqPpoHNHygCla8a9E16uB6CIoNni7ZznYWsLpQ3dFmgHmeebfJtb8RVXgadvBoR/eMhyawzRB7wszQ7Xh+R5Qmi7XbAq8JdJVxqTUi0FtQbXTZ2WZdK4u3NjmmQYTjHXjg7cWfhb2WTF0F34Li1/GlZzYk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769614727; c=relaxed/simple; bh=f9w73AH8W1R9VEx0owRCcnEezKDwk/aaZwAJJogSbJE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hLvKVWlF4etvs6NNr3ocKkVIsW0BTOZyqxMX6jPRN04eJh+aU4PaZXwsEBF3CFCmjPh3shkFUCekfvxwJem2d/+Q9xHT7IYyoO1l+Yt658ZUyYnWqIkko0/5zVbvrNdqi8aCWBAfPA/DJUqprf6kZ+eXl5Kc9CiKR7GUbmsNBGE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=PisLz4OX; 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="PisLz4OX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A26D0C2BC87; Wed, 28 Jan 2026 15:38:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1769614727; bh=f9w73AH8W1R9VEx0owRCcnEezKDwk/aaZwAJJogSbJE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PisLz4OXUtQn6MiDdGaQWWGsGsq/1+6gt6zionbrkP6ebptFcn/Or5YYDhm7peYqs hcdM+gzpG8kWbwPVINxgWf3h9lse9ycxlg0wGbTYxpLBlm9EVGGmrHk1XIbzgZLqjp dVZzykBUA13Z3QISDXZEQMbaiRd2JfhMPONe/t0o= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Marc Kleine-Budde Subject: [PATCH 6.6 224/254] can: esd_usb: esd_usb_read_bulk_callback(): fix URB memory leak Date: Wed, 28 Jan 2026 16:23:20 +0100 Message-ID: <20260128145352.845702637@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260128145344.698118637@linuxfoundation.org> References: <20260128145344.698118637@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Marc Kleine-Budde commit 5a4391bdc6c8357242f62f22069c865b792406b3 upstream. Fix similar memory leak as in commit 7352e1d5932a ("can: gs_usb: gs_usb_receive_bulk_callback(): fix URB memory leak"). In esd_usb_open(), the URBs for USB-in transfers are allocated, added to the dev->rx_submitted anchor and submitted. In the complete callback esd_usb_read_bulk_callback(), the URBs are processed and resubmitted. In esd_usb_close() the URBs are freed by calling usb_kill_anchored_urbs(&dev->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 esd_usb_close(). Fix the memory leak by anchoring the URB in the esd_usb_read_bulk_callback() to the dev->rx_submitted anchor. Fixes: 96d8e90382dc ("can: Add driver for esd CAN-USB/2 device") Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20260116-can_usb-fix-memory-leak-v2-2-4b8cb2915571@pengutronix.de Signed-off-by: Marc Kleine-Budde Signed-off-by: Greg Kroah-Hartman --- drivers/net/can/usb/esd_usb.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) --- a/drivers/net/can/usb/esd_usb.c +++ b/drivers/net/can/usb/esd_usb.c @@ -539,13 +539,20 @@ resubmit_urb: urb->transfer_buffer, ESD_USB_RX_BUFFER_SIZE, esd_usb_read_bulk_callback, dev); + usb_anchor_urb(urb, &dev->rx_submitted); + retval = usb_submit_urb(urb, GFP_ATOMIC); + if (!retval) + return; + + usb_unanchor_urb(urb); + if (retval == -ENODEV) { for (i = 0; i < dev->net_count; i++) { if (dev->nets[i]) netif_device_detach(dev->nets[i]->netdev); } - } else if (retval) { + } else { dev_err(dev->udev->dev.parent, "failed resubmitting read bulk urb: %d\n", retval); }