Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1775884pxp; Mon, 7 Mar 2022 02:03:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJyjPyH/ujRzx83AQ3dAOpzi/BoWxKUb7iIFdx6CvLL8GCNc8P7Mp8vVVtLSYpm+OUUgIj3h X-Received: by 2002:aa7:d5d9:0:b0:416:1dd3:7714 with SMTP id d25-20020aa7d5d9000000b004161dd37714mr9960493eds.256.1646647384698; Mon, 07 Mar 2022 02:03:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646647384; cv=none; d=google.com; s=arc-20160816; b=Plc7fXtDzMTf9WfBFMgdSlldGAx3WqTtyKBCuGsbzuojN1Qt/l5i39f1+B2UJTvJnA Uw5JswgU+T1S8nW5847kIH8q1Ls0w4P9Aq/EntnwlWgyllvf+gfacuFPufS9TIYeRkq9 baHObC82K+vQrXe2oFSiuvh4fATsAtnWarsJRybFFtAUlRmx6kXDvXYJKoh1oxVvllZ4 gEs2QamSY6M3kt38XBdxdLtfuViqr1ASxebxlANBnNAyQ12BsVvKmS69eFgNGcwt0psm Yr794SUQ9x3ZMg1l0vPIYQO8r8FQ4jQibmAAgO7Jw9rQncnyLndhcq1ylDOGQKcsDVia Agag== 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=j5bAUPnNNwG23l1wqc0VE03ZRKnbaJ/81OD2ia9OXTJRZ5O59dBBRvyiHC840KkeXP 9rg+smDRtcnoWwKKQC1YZOCEn/macEaTaWM41SZFQuAXf4miv9ghFd3q4i328A/HQ8Ai /PvTQ/7BQ3JxBCo1gOKuNavAUfmEGtwJVH9jR6e7QBeh4W5vdFo1uOejrNxwrUoG1o8H KurucpVhFD27P9slKV1ffOaBnI61vVQG2cx/lsH/LGjYHZAPdxGYqP8isf3EO7XeegsD GU1YcNtcEqGPIdpXFjsSLP5TXWt57X7SNVqGKTask0fkIuH0AoV+AZyQyhMnc0g1W70w cwOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ywHUzAkR; 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 5-20020a508e45000000b00411cd1b7b45si9673437edx.172.2022.03.07.02.02.42; Mon, 07 Mar 2022 02:03:04 -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=ywHUzAkR; 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 S236928AbiCGJ0Q (ORCPT + 99 others); Mon, 7 Mar 2022 04:26:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236653AbiCGJWi (ORCPT ); Mon, 7 Mar 2022 04:22:38 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D130527ED; Mon, 7 Mar 2022 01:20:48 -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 E5711B810BD; Mon, 7 Mar 2022 09:20:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 486BDC340E9; Mon, 7 Mar 2022 09:20:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646644846; bh=rEQmAFSM5skYf2Cxsh8HavJvc5jurQZGsLq/sl+SbUI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ywHUzAkR6YGwueealA0ulPMGXFpn7Cu2qbuQX+WbvZk0ih8QsnbVzytysOOKBIolm E5K2Wpong+ve89DDN1pTF7SVFEyk4bUtZ1gIP/swKgNr3+YIHFexLUzQJgpU0j2gxA IXarKaOaWXeiMg9i1wGi9NPFDllrJo5YHh+lrr9E= 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.9 09/32] usb: gadget: dont release an existing dev->buf Date: Mon, 7 Mar 2022 10:18:35 +0100 Message-Id: <20220307091634.707872973@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091634.434478485@linuxfoundation.org> References: <20220307091634.434478485@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;