From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 3F9FB306754; Fri, 7 Aug 2026 15:46:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786117599; cv=none; b=V4uzjjgQ2mrKmPhGbD+rmIOJ2K6/pen/TU4Hnkve1Q0VYKMqlUj32ejynGcTIevfmafU1ojeZoa4+oi1c3iTgGD2/eSN1ScvEWl4cADge9oZvr/dCoUa2bln+v5aHi0lrl071BtsymMm6jwGxMEcZV8f5CpoIOD++FusgdskTNc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786117599; c=relaxed/simple; bh=vIB6GWrPs0wsaxysk1XVQcmUq3vZR5CRpMrPb0YOkW8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F8uIgQnDqja++ZcEHxzqHxaKAWe1KldsP0t2PyLYYWdALuOFckZh1/+b9wD50+1WKpoJ1z0xEIkqYxrwE9rFqRaYCl6ueL4xMZsQLJsOwHp16yQL4o+f5vL+K7V3TcOsCer0iKeElhq+8xKQiP60HCsADqD6NnLcJlVzViQVNtE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ENX6JCoT; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="ENX6JCoT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 93CD61F000E9; Fri, 7 Aug 2026 15:46:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1786117598; bh=4EVSdgECYweEqWsOGpVupdD9UfbzJZ1+C98CzkMDkMU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ENX6JCoTnD27Y4zA771e4xIoTyMpu54/Vg8L1oeHcWAJu2cMQenRU0ntVUwTJqN95 2dbwZ1fvbhI38ag3VJrPrf3HOyWzWmWL7szzzmwG7ea8xtGMuQr0hrftbfDqSe4Mff wrQdJhPtZUJJki3momJziHvXMn2OGxbL97BWaVic= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Maoyi Xie , Vincent Mailhol , Marc Kleine-Budde Subject: [PATCH 7.1 375/438] can: peak_usb: peak_usb_start(): fix double free of transfer buffer on URB submit error Date: Fri, 7 Aug 2026 16:39:31 +0200 Message-ID: <20260807143435.961781712@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260807143428.008222056@linuxfoundation.org> References: <20260807143428.008222056@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 7.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Maoyi Xie commit 9b3d5a6d952c38bbcf07f903cbeadefdb56b9bc9 upstream. In peak_usb_start(), each RX URB transfer buffer is allocated with kmalloc() and the URB is flagged URB_FREE_BUFFER so that the final usb_free_urb() also frees the transfer buffer. If usb_submit_urb() fails, the error path frees the buffer explicitly with kfree(buf) and then calls usb_free_urb(urb). Because URB_FREE_BUFFER is set, usb_free_urb() -> urb_destroy() frees the same buffer a second time, a double free of the transfer buffer. BUG: KASAN: double-free in usb_free_urb.part.0+0x91/0xb0 Free of addr ffff8881069ccb80 by task trigger.sh/285 Call Trace: kfree+0x113/0x3c0 usb_free_urb.part.0+0x91/0xb0 Drop the redundant kfree(buf); usb_free_urb() already releases the transfer buffer. This mirrors commit 03819abbeb11 ("net: usb: lan78xx: Fix double free issue with interrupt buffer allocation"). Fixes: bb4785551f64 ("can: usb: PEAK-System Technik USB adapters driver core") Closes: https://lore.kernel.org/linux-can/178159320216.2154888.16953451793788581739@maoyixie.com/T/#u Cc: stable@vger.kernel.org Signed-off-by: Maoyi Xie Reviewed-by: Vincent Mailhol Link: https://patch.msgid.link/178163373110.2507866.216458825145756798@maoyixie.com Signed-off-by: Marc Kleine-Budde Signed-off-by: Greg Kroah-Hartman --- drivers/net/can/usb/peak_usb/pcan_usb_core.c | 1 - 1 file changed, 1 deletion(-) --- a/drivers/net/can/usb/peak_usb/pcan_usb_core.c +++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.c @@ -470,7 +470,6 @@ static int peak_usb_start(struct peak_us netif_device_detach(dev->netdev); usb_unanchor_urb(urb); - kfree(buf); usb_free_urb(urb); break; }