Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7250136rwb; Wed, 23 Nov 2022 04:20:25 -0800 (PST) X-Google-Smtp-Source: AA0mqf5m7LIoRv5FM3/Wi3GqdQebD5c/zvZ1wekaHUvbfdQgpXF8pvqknCaOll/rGKWRF4SGxNsH X-Received: by 2002:a17:906:8a57:b0:7ad:a030:4915 with SMTP id gx23-20020a1709068a5700b007ada0304915mr23648388ejc.267.1669206025026; Wed, 23 Nov 2022 04:20:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669206025; cv=none; d=google.com; s=arc-20160816; b=DvfZksFw3YeJ2ujHPV2uYO0JrZkskRgjWAuxkiQ6SuAH7jF1p4+pV0RuBT1roKDqhP VW0tX2L1VEfdi8vn/oZHP+LAFzhJqepWKOA1qFy/0beSVqUcq+BTTZdnVprmvN3PpeqD hD6gRNnHZ0vSpaVTLnaT1zye0OqJF5y3HfeSI1Bab3jRzqEI1crxhdprKDpBsgHqqk8J +B/YQFRVTT8xwYQG8MaAe4xP2YuLuhdT9MlELCuufdUEm+cF49jw2b2191L/owAmjSgM 2LXJZbOmQG3J7cLZfdcmHJgtui3AulkP16z+VFVAuawFcm1E5RnS1TnbqEYepCIl+TUI mj/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=COAlpSpV1OrjpxVhRD2e+ZrgidH3ASqUN72Rs13mgEM=; b=el0OhRb590za5Ci9TUBRsynzBBLgAHdccGsqWswLQmYQKj2xY7cxERJUWvpjKv5tns bvURYVeIjb0ARsGzS1a+T0KuuFi+pOkr1NqHAt00p/yI8czN/FDiwXruQOG5Fha6+34n 3GxYeRSVfL3AOli39h5uENFaSqlxpUfWnQxgLt8g4/5zHr1OyqkAnTNTRjxcLVg/wpCt 2Y9BV+l5WDu5WVVUdaTHXp6Kg7rNCoRosmVZxItSC9QVp/LMdGXVb1ujiLSUjx0s/u8A nlRDmUlZPmXFLv1apxyRb6Ad0tzWzYs+0bOXp/OwtzERJ8ACpIaiU80bYg6bJIQAikRl Jj8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=hbEH8JPT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b8-20020a056402278800b0045c7611d8ddsi14624937ede.179.2022.11.23.04.20.02; Wed, 23 Nov 2022 04:20:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=hbEH8JPT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236936AbiKWLzU (ORCPT + 89 others); 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 X-Spam-Status: No, score=1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_SBL_CSS, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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); > }