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=1796381846; b=45nSnn5xZNiDv99SR2X6LgbpId/iecHpDZ1vUOex2hYoqJOEGOC+xCoaWsvjHskTHY2F 9K3325gO6AY4rePj+YpKjTiLPtXZm7ZgTKa5BcZaIKCdH0maxljP91xKeDoE2NO6FPRZI QGTzQM+L2IofFk55mxYqtpi3pl/AWy85sjE6PTMdo6iNqllszCyb1lN19Gmhx0moLyJAA 4NKshlzRfAgzqI33Mw/nA/XOKchCOMi8wi21sCy5AvP0lhETvFWnVd6CdfV7PCUAXdrK3 7uuEVimxS0dTJuO9ECXZdnns5kkhAfl6DZVk/gHj+Tx9kAiYnCyyqAyzpQW1496OG6g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381846; 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=PXB2Qx9BZLBviUo1Q3b8yqa04O858it3Q160ff9YIRk=; b=ubAUnj0RRIkQhO859IwMz46w0QiUYbFiOtfV7rzA3PQugezbj6kNt2AlWCATN5+d9Ui2 wXg8TWVIOYkq4c/DdFbw2cVybOaTdqFc7qEGv9bhiIoE3sgN8kLrShWzD+G2jz+P+U1wp DSSxOxP2w6TLhOUQT1qq8EPeVevlJd528DLvrrEXV+TuNl1OzcCER3Lgf7cQBlsbXeXwC aiEsKbpy0kxVeBZE3tCZLE5dK3dY+IpxC+f2UAHvTL3zv99h6GbCeX37Me9mZ6TTwL0b0 Q/3lrpSDPVFeTtLgWHfe9A4Dx+JheLcz91fFBeLLESBZyD7pT5se60o6UOqMdf2jZIA== 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=vVQwRrGR; 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 9F0B9606A322; Fri, 4 Dec 2026 10:57:26 +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=vVQwRrGR Received: by smtp.kernel.org (Postfix) with ESMTPSA id 175F81F000C2; Fri, 4 Dec 2026 10:57:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796381846; bh=PXB2Qx9BZLBviUo1Q3b8yqa04O858it3Q160ff9YIRk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=vVQwRrGRdpIZj9uLn9bGEhnbfHaycmzkEM7UieNG/jjjtz/Q7/bZMccKdD5e0BtKo vyK9Na4MW1GfNKPyul3Lbf1rihqO5htwR+ZUbvomC3GnjBZ93IFc7OpLJxkTDlHgUf CFtGPzo8bR0Wa726K0zxp+Inq6VVAlsV7rlJVhkQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Shunbo Shi , Sasha Levin Subject: [PATCH 6.18 200/703] usb: gadget: f_hid: fix get_req leak when usb_gstrings_attach() fails Date: Fri, 4 Dec 2026 19:01:39 +0900 Message-ID: <20261204100633.172558823@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-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 a31ab0624745c..db243f3d688e0 100644 --- a/drivers/usb/gadget/function/f_hid.c +++ b/drivers/usb/gadget/function/f_hid.c @@ -1178,8 +1178,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