Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1776068pxp; Mon, 7 Mar 2022 02:03:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJyd2udG7nxXx5GlXLhlgWHV2eYF/8ZI54lMujm09ZobuXMR8ttz/W9R+eh0NwpAQyIUqUy8 X-Received: by 2002:a17:907:9605:b0:6d7:24d1:f4ce with SMTP id gb5-20020a170907960500b006d724d1f4cemr8258570ejc.524.1646647397560; Mon, 07 Mar 2022 02:03:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646647397; cv=none; d=google.com; s=arc-20160816; b=FkXrS5AHV+aGihSNv+Iexq5CbSPrZLcZEndyqcFQycl6XcZ2ZMAOOBPhM2FjbK1y+d JLBP8O2fQH5LZriO359kFrYe5P7AQ9zEFjtbdnnLJWaDS8jK3LAKts6Qc6WlgaVlEx0j qpWliig0bQ6zX5uP+/9eeXDLFGcCZy3yh4mRG37IfXPvTsxxY4lO4W6NL0XCIqT9AK6M t6QkptuLANDKa0YhYwossnPVHGVU+7yyEE7psBsgtOcgmbIYvcRU/59dC8HS7+fQheu4 vr2pS7s6fX5/xNw8jKa7/DQLX2FZQjIij32MaC1YGDwhmaY5YXV5J63q0nLSVB/sWSuE a0iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=El4TC4+yRUkaTDgnLV2U/P7QCOPbpGojDDV9Sd82SF8=; b=tMDLBxC5QfZqQ/EH9oxfJqI3Upwt1HdDS+BTlimCAxjvFlN0uKfPWPkcQEC8W9FoFL X6CPRoHNtOMV9yy5vooYz/wq5S3PGEVl8/Q5o6L+jPgkisp6aRvh+X43qH5/GZJ8awwT t6GlWIpmJUn36KUUxnXomJdBBS8omq3Tuxv5kWpfBjdHO25aTSKMYg57rvI12jwPupXI L8cKgz+PgwIrlpox38WeCIqZykuDdEh+AdXcnLDBR/UIPM31vvy4CFSZ9dCvbQ2sa3a5 shCE78sU/r4G6WncxXImojD78bdllp1sLKJNqp1O4/Gb1lxczKbdTVted5ie7OvOgqHr quzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="z8uuX6T/"; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z15-20020a056402274f00b0041330ad6045si10263554edd.567.2022.03.07.02.02.54; Mon, 07 Mar 2022 02:03:17 -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=@linuxfoundation.org header.s=korg header.b="z8uuX6T/"; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236953AbiCGJ1G (ORCPT + 99 others); Mon, 7 Mar 2022 04:27:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236918AbiCGJXL (ORCPT ); Mon, 7 Mar 2022 04:23:11 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 606D865794; Mon, 7 Mar 2022 01:21:25 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 154F6B810BC; Mon, 7 Mar 2022 09:21:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 622ECC340E9; Mon, 7 Mar 2022 09:21:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646644882; bh=rEQmAFSM5skYf2Cxsh8HavJvc5jurQZGsLq/sl+SbUI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=z8uuX6T/vCWB9HZim4GRQs/PMf2LoH4j1ZZZL8cAOoiHvu23CcZFHTNYi7sQlNtIY ogaUhdRaKtLq/Yvh6pv9UYWuZXz2wmwt3qbBOFVYRsVzNi6ZMeZIjJjdv1bnuwH61h Sq0cl3eFO61Ya/86386HiwxP3DpLPc29cUCp+WnA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alan Stern , Hangyu Hua Subject: [PATCH 4.14 10/42] usb: gadget: dont release an existing dev->buf Date: Mon, 7 Mar 2022 10:18:44 +0100 Message-Id: <20220307091636.450594266@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091636.146155347@linuxfoundation.org> References: <20220307091636.146155347@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 From: Hangyu Hua commit 89f3594d0de58e8a57d92d497dea9fee3d4b9cda upstream. dev->buf does not need to be released if it already exists before executing dev_config. Acked-by: Alan Stern Signed-off-by: Hangyu Hua Link: https://lore.kernel.org/r/20211231172138.7993-2-hbh25y@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/legacy/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/usb/gadget/legacy/inode.c +++ b/drivers/usb/gadget/legacy/inode.c @@ -1833,8 +1833,9 @@ dev_config (struct file *fd, const char spin_lock_irq (&dev->lock); value = -EINVAL; if (dev->buf) { + spin_unlock_irq(&dev->lock); kfree(kbuf); - goto fail; + return value; } dev->buf = kbuf;