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 BC72BC433F5 for ; Fri, 31 Dec 2021 17:34:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231524AbhLaRes (ORCPT ); Fri, 31 Dec 2021 12:34:48 -0500 Received: from netrider.rowland.org ([192.131.102.5]:48565 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S229690AbhLaRer (ORCPT ); Fri, 31 Dec 2021 12:34:47 -0500 Received: (qmail 1135115 invoked by uid 1000); 31 Dec 2021 12:34:46 -0500 Date: Fri, 31 Dec 2021 12:34:46 -0500 From: Alan Stern To: Hangyu Hua Cc: balbi@kernel.org, gregkh@linuxfoundation.org, axboe@kernel.dk, dan.carpenter@oracle.com, jj251510319013@gmail.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 1/2] usb: gadget: don't release an existing dev->buf Message-ID: References: <20211231172138.7993-1-hbh25y@gmail.com> <20211231172138.7993-2-hbh25y@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211231172138.7993-2-hbh25y@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jan 01, 2022 at 01:21:37AM +0800, Hangyu Hua wrote: > dev->buf does not need to be released if it already exists before > executing dev_config. > > Signed-off-by: Hangyu Hua > --- Acked-by: Alan Stern > drivers/usb/gadget/legacy/inode.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/gadget/legacy/inode.c b/drivers/usb/gadget/legacy/inode.c > index 3b58f4fc0a80..eaad03c0252f 100644 > --- a/drivers/usb/gadget/legacy/inode.c > +++ b/drivers/usb/gadget/legacy/inode.c > @@ -1826,8 +1826,9 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr) > spin_lock_irq (&dev->lock); > value = -EINVAL; > if (dev->buf) { > + spin_unlock_irq(&dev->lock); > kfree(kbuf); > - goto fail; > + return value; > } > dev->buf = kbuf; > > -- > 2.25.1 >