Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7252159rwb; Wed, 23 Nov 2022 04:21:57 -0800 (PST) X-Google-Smtp-Source: AA0mqf5CZiBg7sbZmW2Tb2Lj1X78tN2ZXClMdzNRWemYUqWW5cFaqs+JgYnYFhZ3Thr6oLoUlHHq X-Received: by 2002:a62:e702:0:b0:573:38f0:c910 with SMTP id s2-20020a62e702000000b0057338f0c910mr8682298pfh.52.1669206116975; Wed, 23 Nov 2022 04:21:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669206116; cv=none; d=google.com; s=arc-20160816; b=qcDg7QueJaaAxJZ1SE1CfxCn2Utj/MekFEP+nrmISXY+gfKwbdXI87NW4GkTLYAJjt KNl/njygqCDZSDcl9u4QcjXT9Ad5BRcbeEmvqsS7s1UAFDj3F6SBj1b4GXZ3Zx+EVm2c KT5mIfAIJrtUqmREOtI+EYzC/f0RX57dgJrGG644Adotv9ijbwGezAqzUfbq3+NZp0f7 HH88ykkuuBGdp6pY8E2UXgNFkGNFmZyVt1II4PHuBD/xiw/yPlukUCHhGoICqRmnOjMY J5mNPJSaaEt1JMn6P3d3e/D/sGwzWSykKazFcZM0VIIO7lBwrz7D31ufiERs5HaXf1Nx f3Pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=5JMIrXWfVVUBawjQhTsB12rkc3V2fqv2OGN2cVRUBRs=; b=vReNPIiV92Mmzok5wJC26goCi/4bHlT9eITIlpeFwXsRo5E9Ws/KaHilRIumcW+hhA LCsPiaXpY4jo7fCOSOVeFWRYXJy97EocCTpBpDsSTKUHahr0i4KX4RqHXbY+90AcVesb HAcKdohiYHs7LLqmjt/rGpyl7eU16SWcrL0+GyjRiUBISrCRPEGPXcYELmAawDC6q7jR ZVCMn9e3BFc+1fD6CI0/EzFGoPWmfJggIEF3d/gAEUPbhTQy+dNV+VDZkeabI508uaSo dvEKDB5sB5gZZtSblFi6r87jhwCdWzeu2Af1zOioMaA8aZ/u4V6msqjZwkYZiNGKfVK0 8QLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@metanate.com header.s=stronger header.b=TN91uAo4; 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=metanate.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p16-20020a17090a931000b00218b346cd3asi1430572pjo.50.2022.11.23.04.21.46; Wed, 23 Nov 2022 04:21:56 -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 (test mode) header.i=@metanate.com header.s=stronger header.b=TN91uAo4; 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=metanate.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237108AbiKWMEj (ORCPT + 89 others); Wed, 23 Nov 2022 07:04:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229472AbiKWMEh (ORCPT ); Wed, 23 Nov 2022 07:04:37 -0500 Received: from metanate.com (unknown [IPv6:2001:8b0:1628:5005::111]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 506E062F6; Wed, 23 Nov 2022 04:04:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metanate.com; s=stronger; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-ID:Content-Description; bh=5JMIrXWfVVUBawjQhTsB12rkc3V2fqv2OGN2cVRUBRs=; b=TN91uAo4CNv5C7fEtaNVdRScjZ r8YBSVaWiMa+2ppar+coZcihrgglWDIJfTsLSaQwpUhf1rVEmcd9kLzW+lXPH6AYxvX3dyTwXxv1x RbvYqzICSadoDgk2up5jwHMyZl4vSrPKOgTmiSFPFOkXKFD/VNmT3ZkuxETK/dTX6VQu+2OBedXun QfvLoZZ9UCnkzlfqSe9uGPcdnsDWWR2c0vhOxejyjs2JoSjgn1QZ1qHA91tVW3WTM0hplyFJRx2WI MKkNKP5+0FMvgjSWMD7G4Y7GKMU8RBa/Buf+T5sUGCT0+61+MnakBdfUCQRcyNmQ3VKs/gwLHOril B1CvOObg==; Received: from dougal.metanate.com ([192.168.88.1] helo=donbot) by email.metanate.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1oxoUU-0007F2-2m; Wed, 23 Nov 2022 12:04:34 +0000 Date: Wed, 23 Nov 2022 12:04:33 +0000 From: John Keeping To: Andrzej Pietrasiewicz Cc: linux-usb@vger.kernel.org, Fabien Chouteau , Peter Korsgaard , Felipe Balbi , Andrzej Pietrasiewicz , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Lee Jones , Alan Stern Subject: Re: [PATCH 2/3] usb: gadget: f_hid: fix refcount leak on error path Message-ID: References: <20221122123523.3068034-1-john@metanate.com> <20221122123523.3068034-3-john@metanate.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Authenticated: YES X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RDNS_NONE,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 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 On Wed, Nov 23, 2022 at 12:55:14PM +0100, Andrzej Pietrasiewicz wrote: > 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 Patch 1 is also a bugfix, I ordered 1 & 2 based on the order of the commits in the Fixes: tags. > 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); > > } >