From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796383414; b=tOTr5Killrs21/wEc8XPHraqhz3mMn91NEYNYVVu9ziDWrRxDNns0bYjATh8CFuLgpJw tZbnzroKRaUiT1I4xr60lxtKIB1Gh/+PUGC1yRPV9EHg7EIIS/GKyio/+GnPA31N0xiZN pxiRRJubX7Bk1ZkqsK5aSxv39aMHbdONFwSN9m//TSFUwxdRieCEFvK/hEe3m+rb0jIy9 eNTH3Z6pLH0TOitVWRog2l2wnMoc+tH1EQenigpUWGlf4elw4/ePzZwY7/Nf9a2YxxfR/ q0vm+iHeC2/8Gj7Lpn1lidFknABxw3q8bM5+rGs1d7F9CBzr7Kozt4UowfSsqltKgvg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383414; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=d7Bxun4rtBvRhTWeoZQE3BTdo8IcbmUP4FZN56J7nhU=; b=nBatF0YJOCiB7TV9d6/RlKfNfy1Bn97MYrBrGK8IfnyCJst/7KQ6vnECOhXXPeCk715D 0o9l7O2twD0w0DL/HouAp1X7rLtu5nn41sKpWvFDnR81utkqmLlQ8w0ps217rsleYPhgb KJ+aPJXoaIROYululrME8HS4urFFQxXij0ndK6fMOcVcWBKoYciwWaqNPUXq6rS03lri9 xSOXnVCaq4oO7agB73BWw6oIzQb+zLd1iEFarTdScURwXDUBPp9H6yJhzlZCL8XtN0QOn qDAXOo7VXmVcDO4YijfzMxrOEorkPDiysraDHiDxPQfQzeSwb38xJXlSNoRoUwT6ObA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=tAxp2wY8; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E51A606A330; Fri, 4 Dec 2026 11:23:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=tAxp2wY8 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 113DB1F000C2; Fri, 4 Dec 2026 11:23:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796383414; bh=d7Bxun4rtBvRhTWeoZQE3BTdo8IcbmUP4FZN56J7nhU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=tAxp2wY8BpWXNLxcmKpjJTy7pMEOKCTB7FdW5FDgkA5wRaVvcQpZH7MFnyzCm+YRR tu97GUKcIcxDj1R9Bc7VMJ6NaOVVhEnbWN4axs1jElndy7HUqUK3JkIylm3tpKii0h RvTwqqk7BemviP6gvaCKd2q5UMIV5pXI464mG6NI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Shunbo Shi , Sasha Levin Subject: [PATCH 6.12 215/555] usb: gadget: f_hid: fix get_req leak when usb_gstrings_attach() fails Date: Fri, 4 Dec 2026 19:04:18 +0900 Message-ID: <20261204100617.108354655@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Shunbo Shi [ Upstream commit f11175ece1250557ec595ea7a2854f0391cab53d ] In hidg_bind(), hidg->get_req is allocated early; if usb_gstrings_attach() subsequently fails, the function returns directly without freeing the request, leaking it. Unwind through the fail path instead. Fixes: a139c98f760e ("USB: gadget: f_hid: Add GET_REPORT via userspace IOCTL") Signed-off-by: Shunbo Shi Link: https://patch.msgid.link/20261117125051.5646-4-shishunbo@cmss.chinamobile.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/gadget/function/f_hid.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c index e3b88af534856..56171e3794cbb 100644 --- a/drivers/usb/gadget/function/f_hid.c +++ b/drivers/usb/gadget/function/f_hid.c @@ -1193,8 +1193,10 @@ static int hidg_bind(struct usb_configuration *c, struct usb_function *f) /* maybe allocate device-global string IDs, and patch descriptors */ us = usb_gstrings_attach(c->cdev, ct_func_strings, ARRAY_SIZE(ct_func_string_defs)); - if (IS_ERR(us)) - return PTR_ERR(us); + if (IS_ERR(us)) { + status = PTR_ERR(us); + goto fail; + } hidg_interface_desc.iInterface = us[CT_FUNC_HID_IDX].id; /* allocate instance-specific interface IDs, and patch descriptors */ -- 2.53.0