From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D7BAC4332F for ; Wed, 23 Nov 2022 11:55:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236837AbiKWLzU (ORCPT ); Wed, 23 Nov 2022 06:55:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236656AbiKWLzT (ORCPT ); Wed, 23 Nov 2022 06:55:19 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBDA5C65; Wed, 23 Nov 2022 03:55:18 -0800 (PST) Received: from [192.168.0.192] (unknown [194.146.248.75]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: andrzej.p) by madras.collabora.co.uk (Postfix) with ESMTPSA id 36AA56601615; Wed, 23 Nov 2022 11:55:17 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1669204517; bh=wGEZtLTeZPeK0VlHGG0r8cTHtzmBHhRkskvyyEeF8Ik=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=hbEH8JPT7PilLf2DAVVEVDOMKY08CG2aj951mgFAevRLQApr3rlh2xn7nCBMYWwEb GlBpQQi82dNvjaUV+DHfRAf0mMKugmhP9G8B7Z6SSI+lUqSjx87IvWPFSjsxXsgOeG tb99bjnnk+A1j/v7C2KgHbPikf6doE1/xh76PhSAj7CUngdl2KOMgDyUheuWmgqSKQ EcQqyPXfncm5dtBnvONUAv/YwkhK28cxKea0c3Rhq25A93l9l0xIS4HEqVjh6JBo64 VaG+PEKMB5G2fjW2mCWfs3PLdxLcrTXpsjQdDu5YJjzULYJGtDJlRcbkpdh7ymfyD6 2Om42pvxy4n/g== Message-ID: Date: Wed, 23 Nov 2022 12:55:14 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [PATCH 2/3] usb: gadget: f_hid: fix refcount leak on error path Content-Language: en-US To: John Keeping , linux-usb@vger.kernel.org Cc: Fabien Chouteau , Peter Korsgaard , Felipe Balbi , Andrzej Pietrasiewicz , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Lee Jones , Alan Stern References: <20221122123523.3068034-1-john@metanate.com> <20221122123523.3068034-3-john@metanate.com> From: Andrzej Pietrasiewicz In-Reply-To: <20221122123523.3068034-3-john@metanate.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org W dniu 22.11.2022 o 13:35, John Keeping pisze: > When failing to allocate report_desc, opts->refcnt has already been > incremented so it needs to be decremented to avoid leaving the options > structure permanently locked. > > Fixes: 21a9476a7ba8 ("usb: gadget: hid: add configfs support") > Signed-off-by: John Keeping I'd personally place the bugfix before patches 1 and 3, but anyway Reviewed-by: Andrzej Pietrasiewicz > --- > drivers/usb/gadget/function/f_hid.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c > index 8b8bbeaa27cb..6be6009f911e 100644 > --- a/drivers/usb/gadget/function/f_hid.c > +++ b/drivers/usb/gadget/function/f_hid.c > @@ -1292,6 +1292,7 @@ static struct usb_function *hidg_alloc(struct usb_function_instance *fi) > GFP_KERNEL); > if (!hidg->report_desc) { > put_device(&hidg->dev); > + --opts->refcnt; > mutex_unlock(&opts->lock); > return ERR_PTR(-ENOMEM); > }