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 368DC2D7DF1; Tue, 21 Jul 2026 22:59:29 +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=1784674770; cv=none; b=jqp8dpF4eM1f/NIStmoYne2DjuSk3EolqG3AbATMCkmxTRaLST5BiH+jC9iUKZGL/qofwGMuAXaD+HQgt6ow1zxJRDlfSz5mPSoHZPfyS8n2x6yGHP9mq8tH/oTBqXH3tp8LR8k8DPvcfJaOUTtV06G9ZHweOzbj2dUWhD2gifU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784674770; c=relaxed/simple; bh=ACRR2x5qUl6jRps6WrXEpxCDn/Yy4MVhLBaVNDKWZnU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NjPqYNOGHeJBQC22XJV4sUKW5rFFB/hIBqvtADgh+GNNQVFA5N4oO7NTEVFSLVzhk6EQvmWG4eQ1upotH20Mey+xwBhKP5R3Qru+e2+uH33NrV6leRKbD5ST9vSMcUVyKqaagu5wKTCpVNyj5vIRGkczLoKIlRZFewwtR+oFseQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=2Dett3u3; 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="2Dett3u3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C9791F000E9; Tue, 21 Jul 2026 22:59:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784674769; bh=aRTr0mtzYV0XphfjwN6GeZYdKxBISPLs1mvxEpBTuEI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=2Dett3u3E+hxOOvpWn+rKFjEcWm1qwe7lW1uDOgeCZxHc943NHg0YPglEu3MPL+Vi wFhHjaP/T36lz8LQfshes7aCMmTa1UocdWKwCWOvGvRS0z/XE/jpecwcNkq6dTsk3B uHGfO8eLZat4RVIipOb0HHoMBk/oSWX2A5S5SIec= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable , Dawei Feng , Alan Stern , Sasha Levin Subject: [PATCH 5.10 665/699] usb: free iso schedules on failed submit Date: Tue, 21 Jul 2026 17:27:04 +0200 Message-ID: <20260721152410.764663682@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152355.667394603@linuxfoundation.org> References: <20260721152355.667394603@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.10-stable review patch. If anyone has any objections, please let me know. ------------------ 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 Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/ehci-sched.c | 11 +++++++++-- drivers/usb/host/fotg210-hcd.c | 6 ++++-- 2 files changed, 13 insertions(+), 4 deletions(-) --- a/drivers/usb/host/ehci-sched.c +++ b/drivers/usb/host/ehci-sched.c @@ -1613,6 +1613,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; @@ -1643,8 +1644,6 @@ iso_stream_schedule( return status; fail: - iso_sched_free(stream, sched); - urb->hcpriv = NULL; return status; } @@ -1956,6 +1955,10 @@ static int itd_submit(struct ehci_hcd *e 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; @@ -2333,6 +2336,10 @@ static int sitd_submit(struct ehci_hcd * 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; --- a/drivers/usb/host/fotg210-hcd.c +++ b/drivers/usb/host/fotg210-hcd.c @@ -4271,8 +4271,6 @@ static int iso_stream_schedule(struct fo return 0; fail: - iso_sched_free(stream, sched); - urb->hcpriv = NULL; return status; } @@ -4566,6 +4564,10 @@ static int itd_submit(struct fotg210_hcd 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;