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 DA12C20E334 for ; Sun, 19 Jul 2026 14:16: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=1784470569; cv=none; b=ViPR+tM/FKUCnDIKMZ/fFmclsQtKdOwXgen7jCclqK9mu8RzgSzmSVqMpmVDeXBByMDxipabUfC9/Q72kwN1a9FDG4v+Ajuz/iyR0qRxrJMAqCqOuZl0O7g1hMXUmIGS/jg1PNNgsgwP3Hfeh7ckn9+0z35bITP2uQuuy2mW7gM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784470569; c=relaxed/simple; bh=JwVW1iLdNcpOUNcIfkyJlG26kHr5dDDK+O11c+hozeQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A6S3kF3991PHKJ1yFC3uKw+F97ZI74IZpc1z54RtS6oZcjVV73KLXIGyyBrG4C4qTgGVJpS5d2+rNuf7eZNKkgA3WEpkO/1Msfz8SMF3a+4ZLM8GULKxC+4t7Lp+xwlRaNpsoJf+cCP5sBCptwcJzulh9O3doBupZ/zB5zqGrs4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=a/BCTScH; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="a/BCTScH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D30B31F000E9; Sun, 19 Jul 2026 14:16:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784470567; bh=/zPMdRqq9WLSV2vy49NdQrITP3rz4u/KPaoAAZIVxmg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=a/BCTScHz4bKzoHAt+Le8BgyEO/fc3WWnxgbFi1CIvW15OHQFZpUiGR3tbtFe72j7 tKXHg6+I12jHXVmZEvoWc0FwcvWmVsszVDEEXrIw018IfbpbeS3MPe0Jryh+VrrB0X D5NIk+PbRb97SVkuVzRkEguYzgTTMgJj9Jepm6eDc+DYt7EVQx54n8Uuw2gVLp11n7 TZgjkQjJDatEJjjw85cK6OY8VWNxCO91s48xdNrPJX1YAX7HdFlftUkGi7Abr5CXGd WgbC2BbybukKv301NExyr5BKVgj0/edMU/6/RkSqFedxCzgji7FS6i93tGKtoD2R5g Vk91U38g06Lrg== From: Sasha Levin To: stable@vger.kernel.org Cc: Dawei Feng , stable , Alan Stern , Greg Kroah-Hartman , Sasha Levin Subject: [PATCH 6.1.y] usb: free iso schedules on failed submit Date: Sun, 19 Jul 2026 10:16:05 -0400 Message-ID: <20260719141605.4055416-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026071433-debating-yonder-99d6@gregkh> References: <2026071433-debating-yonder-99d6@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Dawei Feng [ Upstream commit b9399d25fbb34a05bbe76eeedd730f62ff2670e9 ] EHCI and FOTG210 isochronous submits build an ehci_iso_sched before linking the URB to the endpoint queue, and keep the staged schedule in urb->hcpriv until iso_stream_schedule() and the link helpers consume it. If the controller is no longer accessible, or usb_hcd_link_urb_to_ep() fails, submit jumps to done_not_linked before that handoff happens and leaks the staged schedule still attached to urb->hcpriv. Free the staged schedule from done_not_linked when submit fails before the URB is linked and clear urb->hcpriv after the free. The bug was first flagged by an experimental analysis tool we are developing for kernel memory-management bugs while analyzing v6.13-rc1. The tool is still under development and is not yet publicly available. Manual inspection confirms that the bug is still present in v7.1.1. An x86_64 allyesconfig build showed no new warnings. As we do not have an EHCI host controller with a USB isochronous device to test with, no runtime testing was able to be performed. Fixes: 8de98402652c ("[PATCH] USB: Fix USB suspend/resume crasher (#2)") Fixes: e9df41c5c589 ("USB: make HCDs responsible for managing endpoint queues") Fixes: 7d50195f6c50 ("usb: host: Faraday fotg210-hcd driver") Cc: stable Signed-off-by: Dawei Feng Reviewed-by: Alan Stern Link: https://patch.msgid.link/20260630071419.349161-1-dawei.feng@seu.edu.cn Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/host/ehci-sched.c | 11 +++++++++-- drivers/usb/host/fotg210-hcd.c | 6 ++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c index bd542b6fc46bda..d002e70171f6c4 100644 --- a/drivers/usb/host/ehci-sched.c +++ b/drivers/usb/host/ehci-sched.c @@ -1623,6 +1623,7 @@ iso_stream_schedule( status = 1; /* and give it back immediately */ iso_sched_free(stream, sched); sched = NULL; + urb->hcpriv = NULL; } } urb->error_count = skip / period; @@ -1653,8 +1654,6 @@ iso_stream_schedule( return status; fail: - iso_sched_free(stream, sched); - urb->hcpriv = NULL; return status; } @@ -1966,6 +1965,10 @@ static int itd_submit(struct ehci_hcd *ehci, struct urb *urb, usb_hcd_unlink_urb_from_ep(ehci_to_hcd(ehci), urb); } done_not_linked: + if (status < 0) { + iso_sched_free(stream, urb->hcpriv); + urb->hcpriv = NULL; + } spin_unlock_irqrestore(&ehci->lock, flags); done: return status; @@ -2343,6 +2346,10 @@ static int sitd_submit(struct ehci_hcd *ehci, struct urb *urb, usb_hcd_unlink_urb_from_ep(ehci_to_hcd(ehci), urb); } done_not_linked: + if (status < 0) { + iso_sched_free(stream, urb->hcpriv); + urb->hcpriv = NULL; + } spin_unlock_irqrestore(&ehci->lock, flags); done: return status; diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c index dc968960769e1b..5cdae91211ece0 100644 --- a/drivers/usb/host/fotg210-hcd.c +++ b/drivers/usb/host/fotg210-hcd.c @@ -4272,8 +4272,6 @@ static int iso_stream_schedule(struct fotg210_hcd *fotg210, struct urb *urb, return 0; fail: - iso_sched_free(stream, sched); - urb->hcpriv = NULL; return status; } @@ -4567,6 +4565,10 @@ static int itd_submit(struct fotg210_hcd *fotg210, struct urb *urb, else usb_hcd_unlink_urb_from_ep(fotg210_to_hcd(fotg210), urb); done_not_linked: + if (status < 0) { + iso_sched_free(stream, urb->hcpriv); + urb->hcpriv = NULL; + } spin_unlock_irqrestore(&fotg210->lock, flags); done: return status; -- 2.53.0