Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp446029rdb; Tue, 5 Dec 2023 09:34:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IFyLzAfkqG5QnfKXDIz8T1TpV2hNbihYr1JxFyAVkjiA3BTuBuvAtSz8tcQBLUCJ/oJQRxA X-Received: by 2002:a05:6358:2611:b0:170:17eb:1e7 with SMTP id l17-20020a056358261100b0017017eb01e7mr3294895rwc.42.1701797671547; Tue, 05 Dec 2023 09:34:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701797671; cv=none; d=google.com; s=arc-20160816; b=CRBVcBiJ8jTuBcN/Z1dL7aTCViZIEPV2EzLXj41MWFjXGoblUGZqGkx2gVykmuMwlR CETvZB9lyj0Cg6Y8TVPqoTiUNAoMkmWs2mNFhcTAUBUscp/y3rA35BbQMBTc4gTV2UYM OyUZfvYiYmV/bicgjt480TB6Pbena4VeGGbvHz+8EbjMqGXXJ/Fc62wBO3N5rwjwgNmZ kwTQSOX3qNUOBhMmgmzFHJlxGgnDDlZhYEQe+TT73aE/tftlyK209vVHG4414ippDfqs w82aPOR1ckTw47PpQBdsy8DhJG9XKVBuaqSrU1lGeJeXo8c8gxjk1bycoCcCKQqOuKDk t2mA== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=zLLHT4UxVPgVscvDiyxDxW0gUHXxZKXuy2aRFfQ0E6I=; fh=x81TYoy6FwWf2CDuPNZKp3ZERlhh9y6GsNm9SKAmKHA=; b=tm522exUrCE5miZE6RrlHaQtWnEiknrj15g8q/r9F9gqIVcdIUVjqbUDqRCLpoCfq+ /9ay9R7tQ4vRE3b8YsXfYBBTp63ASLhOeFwOCvsfEKHFJOq5Nc8XedjEjlDJRzzxQ8+B oPFMudlR73S20llm62iJ/eLotA5bEOJomNsnpkT+TEBUD1lVKZJjJ+FADyVhpVCkHXk9 n2f/b8TO+EiSUYd/9eN9X8oBPYaMI54q1f2I3kg0d1mqNK6KSx6qydfsn3LdTh1iDfo+ KpuDuBYtyScXYA3zJ3KaVryd/sZe4APpOx1WwT1BL34PuK/0XFAd6+IZECZlLskrlEcJ x8eQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ed+fczkA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id h2-20020a655182000000b005c64e8141b8si6632937pgq.101.2023.12.05.09.34.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 09:34:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ed+fczkA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id D3B918042020; Tue, 5 Dec 2023 09:34:26 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229710AbjLEReC (ORCPT + 99 others); Tue, 5 Dec 2023 12:34:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346213AbjLERd7 (ORCPT ); Tue, 5 Dec 2023 12:33:59 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1388D50 for ; Tue, 5 Dec 2023 09:34:05 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F253C433A9; Tue, 5 Dec 2023 17:34:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1701797645; bh=jgbfGbZsBewA51hOqnV3bW8oStFg/dIzf/WIRR7nJ1U=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Ed+fczkAv4EknCnLYlOvj2wiiJNrkWIgDfUzHEIAZG7ya5RsdMc0xMe9jBzcbl3du oJPL8B8kemEQcMD2/WjDoIsiepE51ryxa7bVvouNiqx9q/k1uH+Vg0OpYQaSSDC3mF buifRcZXf4IqzZszVKuUicz6PTYPipl34IyydYzM= Date: Wed, 6 Dec 2023 02:33:58 +0900 From: Greg KH To: Konstantin Aladyshev Cc: benjamin.tissoires@redhat.com, ivan.orlov0322@gmail.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, john@keeping.me.uk, lee@kernel.org Subject: Re: [PATCH 1/1] usb: gadget: f_hid: fix report descriptor allocation Message-ID: <2023120650-scroll-studio-1083@gregkh> References: <20231205085404.175-1-aladyshev22@gmail.com> <20231205085404.175-2-aladyshev22@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231205085404.175-2-aladyshev22@gmail.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 05 Dec 2023 09:34:27 -0800 (PST) On Tue, Dec 05, 2023 at 11:54:03AM +0300, Konstantin Aladyshev wrote: > The commit "usb: gadget: f_hid: fix f_hidg lifetime vs cdev" > (89ff3dfac604614287ad5aad9370c3f984ea3f4b) has introduced a bug > that leads to hid device corruption after the replug operation. Nit, this should be written as 89ff3dfac604 ("usb: gadget: f_hid: fix f_hidg lifetime vs cdev") right? > Reverse device managed memory allocation for the report descriptor > to fix the issue. > > Tested: > This change was tested on the AMD EthanolX CRB server with the BMC > based on the OpenBMC distribution. The BMC provides KVM functionality > via the USB gadget device: > - before: KVM page refresh results in a broken USB device, > - after: KVM page refresh works without any issues. > > Signed-off-by: Konstantin Aladyshev We need a Fixes: tag here and also a cc: stable so that this gets properly backported. > --- > drivers/usb/gadget/function/f_hid.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c > index ea85e2c701a1..3c8a9dd585c0 100644 > --- a/drivers/usb/gadget/function/f_hid.c > +++ b/drivers/usb/gadget/function/f_hid.c > @@ -92,6 +92,7 @@ static void hidg_release(struct device *dev) > { > struct f_hidg *hidg = container_of(dev, struct f_hidg, dev); > > + kfree(hidg->report_desc); > kfree(hidg->set_report_buf); > kfree(hidg); > } > @@ -1287,9 +1288,9 @@ static struct usb_function *hidg_alloc(struct usb_function_instance *fi) > hidg->report_length = opts->report_length; > hidg->report_desc_length = opts->report_desc_length; > if (opts->report_desc) { > - hidg->report_desc = devm_kmemdup(&hidg->dev, opts->report_desc, > - opts->report_desc_length, > - GFP_KERNEL); > + hidg->report_desc = kmemdup(opts->report_desc, > + opts->report_desc_length, > + GFP_KERNEL); Yet one more reason why devm_*() functions are dangerous to use :( Nice fix. thanks, greg k-h