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 498B1274B29; Tue, 21 Oct 2025 20:07:42 +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=1761077262; cv=none; b=IH8wgo52wwQwjw6/oZAwB8yePVclMHjfjSYCNuCpK2KNCz63qeKqmnmR2gttlVrv7eAd2Fr5ZeNBH9n2wlpQ7f5cXmrOMnrySYHjRuEIVvQ2awSQpxu0YePzIyj4T1Y7FZCx0E7yU/QptImcrPuHL7naV3pK1akNpU3noDgF1kM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761077262; c=relaxed/simple; bh=p2R78rzEhj94emMx4/RYg7MPYECBtJyytqVY9hK5jC4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=q7D7PmgJqwNtRuLosG+TiwIOT63Rd3v2HMH001HesKBxzsP0AwZ78q/PXQfMQaevw6qg+3LUQv3Tae6R1fpMBtlQ5TgtzuPULYvDFSpMy/KL2cE9gGAO6RtelcLdk03j3dmOZGUIqTmgyBnqLWUG7Us2r/jsY3a7l0o510O7Ut0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=eahYm+R7; 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="eahYm+R7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C93AAC4CEF7; Tue, 21 Oct 2025 20:07:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1761077262; bh=p2R78rzEhj94emMx4/RYg7MPYECBtJyytqVY9hK5jC4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eahYm+R7TKr7PW9fXcIZWy8PgxPmdo1lQM+r9/1wRaZGwL6Fwt0fIIoPNdVsS5s+e FnNCLja8iYQ8vEbEhCf2TzqLIXQXS9ymj8jbE7GU2RRWuz2j5L/A4t3O2nfHqzE6uK OXrIuVJxLjk1lqHqD7KdT8Sovfcg3PeKPjnepdpQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Kuen-Han Tsai , Sasha Levin Subject: [PATCH 6.17 051/159] usb: gadget: Store endpoint pointer in usb_request Date: Tue, 21 Oct 2025 21:50:28 +0200 Message-ID: <20251021195044.442103756@linuxfoundation.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251021195043.182511864@linuxfoundation.org> References: <20251021195043.182511864@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.17-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kuen-Han Tsai [ Upstream commit bfb1d99d969fe3b892db30848aeebfa19d21f57f ] Gadget function drivers often have goto-based error handling in their bind paths, which can be bug-prone. Refactoring these paths to use __free() scope-based cleanup is desirable, but currently blocked. The blocker is that usb_ep_free_request(ep, req) requires two parameters, while the __free() mechanism can only pass a pointer to the request itself. Store an endpoint pointer in the struct usb_request. The pointer is populated centrally in usb_ep_alloc_request() on every successful allocation, making the request object self-contained. Signed-off-by: Kuen-Han Tsai Link: https://lore.kernel.org/r/20250916-ready-v1-1-4997bf277548@google.com Signed-off-by: Greg Kroah-Hartman Link: https://lore.kernel.org/r/20250916-ready-v1-1-4997bf277548@google.com Stable-dep-of: 082289414360 ("usb: gadget: f_rndis: Refactor bind path to use __free()") Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/udc/core.c | 3 +++ include/linux/usb/gadget.h | 2 ++ 2 files changed, 5 insertions(+) --- a/drivers/usb/gadget/udc/core.c +++ b/drivers/usb/gadget/udc/core.c @@ -194,6 +194,9 @@ struct usb_request *usb_ep_alloc_request req = ep->ops->alloc_request(ep, gfp_flags); + if (req) + req->ep = ep; + trace_usb_ep_alloc_request(ep, req, req ? 0 : -ENOMEM); return req; --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -32,6 +32,7 @@ struct usb_ep; /** * struct usb_request - describes one i/o request + * @ep: The associated endpoint set by usb_ep_alloc_request(). * @buf: Buffer used for data. Always provide this; some controllers * only use PIO, or don't use DMA for some endpoints. * @dma: DMA address corresponding to 'buf'. If you don't set this @@ -98,6 +99,7 @@ struct usb_ep; */ struct usb_request { + struct usb_ep *ep; void *buf; unsigned length; dma_addr_t dma;