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 7EDC747AF75; Thu, 20 Aug 2026 16:32:07 +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=1787243529; cv=none; b=TNI+lNJ4VRW7QmQ8Eq54lruVa2tAVAGACHrAjm2O+/O5jF1bVIFOyWJaGM1rsa60UR1MIdYmHjPUFObgmB6GbItAnvF5sIdRyfdRTuB8/zgGHXBfUwoPbTZdC2Y7NP2DmC0eShBseUMlZqdmLKIBSYMqCMlixE95lcE9CDFZmNo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787243529; c=relaxed/simple; bh=MQ/XhwNs0szScnswliV87YTFNmq+oEOYhGHOxOztJs0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eM5pPqABTgkTXc8hzSmKS6xCubA9IHcE3a8+nbk3PTF5EoMKv1wd/NROdEAwQPRugmK332nCMtan9tD9b/We/LSD9VLIdjCHMs2qiR9SSSo6t/pRn6bUnQ556jsOCPNmtUTE04EGVz2/uFyUHJK+KXqGsRIzASbRVb9hrLQhyjU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ll1qsPni; 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="ll1qsPni" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D96D51F00A3A; Thu, 20 Aug 2026 16:32:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1787243527; bh=le7CV7CHg8XfAwmMgg5fVQBe4wN//Icx5OLXQNwEd1U=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ll1qsPni7+XYLTOUmy6bkEA1QegMTorDgeAGJbpV6M+wJw98ctnj7w67KLAr3I4Gg X1FLdDVOjw2ldr1hZ04+Dr0IwGn8rnownNXEU1EHeYoSUYnjfvveffomWnZdjUIfvu sdezD9f0oxhJ7WcWADvIg49CV/WmImqnVaENw5fU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Fan Wu , Marc Kleine-Budde , Sasha Levin Subject: [PATCH 5.15 126/272] can: esd_usb: kill anchored URBs before freeing netdevs Date: Thu, 20 Aug 2026 16:55:10 +0200 Message-ID: <20260820145235.042892077@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260820145231.229664293@linuxfoundation.org> References: <20260820145231.229664293@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: Fan Wu [ Upstream commit c43122fef328a70045fe7621c06de6b2b8e19264 ] esd_usb_disconnect() frees each CAN netdev with free_candev() inside its per-netdev loop and only calls unlink_all_urbs(dev) afterwards. The per-netdev private data (struct esd_usb_net_priv) is embedded in the net_device allocation returned by alloc_candev(), so once free_candev() has run, dev->nets[i] points to freed memory. unlink_all_urbs() then dereferences the freed dev->nets[i] to kill the per-netdev TX anchor (usb_kill_anchored_urbs(&priv->tx_submitted)), clear active_tx_jobs, and reset priv->tx_contexts[]. Reorder the teardown so the anchored URBs are killed before the netdevs are freed, matching other CAN/USB drivers in the same directory such as ems_usb, usb_8dev and mcba_usb, which unregister, then unlink, then free: unregister the netdevs first (which stops their TX queues), call unlink_all_urbs(dev) once, then free the netdevs. This issue was found by an in-house static analysis tool. Fixes: 96d8e90382dc ("can: Add driver for esd CAN-USB/2 device") Cc: stable@vger.kernel.org Assisted-by: Codex:gpt-5.5 Signed-off-by: Fan Wu Link: https://patch.msgid.link/20260709164159.497640-1-fanwu01@zju.edu.cn Signed-off-by: Marc Kleine-Budde Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/can/usb/esd_usb.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/drivers/net/can/usb/esd_usb.c +++ b/drivers/net/can/usb/esd_usb.c @@ -1151,10 +1151,13 @@ static void esd_usb2_disconnect(struct u if (dev->nets[i]) { netdev = dev->nets[i]->netdev; unregister_netdev(netdev); - free_candev(netdev); } } unlink_all_urbs(dev); + for (i = 0; i < dev->net_count; i++) { + if (dev->nets[i]) + free_candev(dev->nets[i]->netdev); + } kfree(dev); } }