Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp3599087pxm; Tue, 1 Mar 2022 01:22:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJxAuAauHFJsSoA65zxEeu1frFmd4vEkqqKI6+K9+jo2I5pBrEt+ToAAsGSPJ01xLlKxh/ev X-Received: by 2002:a63:534d:0:b0:374:da8c:ad53 with SMTP id t13-20020a63534d000000b00374da8cad53mr20874245pgl.100.1646126531185; Tue, 01 Mar 2022 01:22:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646126531; cv=none; d=google.com; s=arc-20160816; b=nmdK5/oSzS07VuX4Ce/nB3YekNJqDO4f/pr6nnNlvnH2yXZ0qpbiR4MgbumZVgOCox GvPYr49djwWTqZ8NLS5uUC5OPTc0uWm+8KeMQCHfqqyi58RbCtwP9cJUEqf9cupyXVPk nnBSB9s4wE8L1/KNpbLTx15dEcYZBKWyKsbsJFNZFCmS2V/NeAfzCk169rXLCHCNmckP drFZqBsVC++jcLSHS3OZ1pw64f85+Ex8d/TLxL3297zGqh1LOPtIq7elfLWsHLwpDjOn K7vHLGIy+w8FXI6bOVUvXMN8j5TiiCcGUEwiJAZOlL0Da52tK/wwfjVLSSlgxp7FqJ/U ZjNg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zsGUyzPwyU2D48eLQi5oVaEc8GeAsTJmPIqyMWCKDVc=; b=tX5sBXnoFh7gehByTx3EIIW/DeLJjSe48ZgRCcQsIAUN7XtGE5cmy0J/mSrEzoDGUl 16sxa75qRYlTTR91GD+NtuiCsGzoc0Y/lC0zBqwshUBwQUi3QpDae7I3ag8v/yhCqOx9 WFQCvL2uPdkvEJwSlFO4HiHD1iLl7UGbc0PpXgryV9YF9UDEcRWiNj6/A6JFpe5qJqOn QVRjEbv6bnzDOw3dq5/j7ajCfHCA5g28ZZijVdwcPLA5gZSX/c31fFwhN2Fqb66K6rid yWY32GdIS7bqbvQQBsJfaaY9zfbQJBKGZ07wBV+fqLsMIrq2ipgg7FrocirWk3hhuwjX iecw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PBxoH++E; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a21-20020a17090ad81500b001beea5972aesi92861pjv.40.2022.03.01.01.21.55; Tue, 01 Mar 2022 01:22:11 -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=@gmail.com header.s=20210112 header.b=PBxoH++E; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229617AbiCAC1H (ORCPT + 99 others); Mon, 28 Feb 2022 21:27:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230197AbiCAC1F (ORCPT ); Mon, 28 Feb 2022 21:27:05 -0500 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E409DF3E; Mon, 28 Feb 2022 18:26:25 -0800 (PST) Received: by mail-pj1-x1044.google.com with SMTP id b8so12827025pjb.4; Mon, 28 Feb 2022 18:26:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zsGUyzPwyU2D48eLQi5oVaEc8GeAsTJmPIqyMWCKDVc=; b=PBxoH++E61U8SoMAfdf8/lkKMP2fB3X7XjKhEiQJwTXYEiWzxFauDPV6rB2idA6+E6 ZbQNd0++9tHFXa55fAWuDA3wymOjt9Ib3UXZGDdzkFM+UIsHBveZHlHspRiACA8owpQm /m3M5qZOWRHrpAlDF3uFM8yyxqZhxFe2DyXw2ym+tB5/hTloKomS/fyu/zxE5/llwRr3 cujV9zrDiubh+GgccgRVqxHn3LLkFh9P0zQ2sVh/Ty2UFRLQHQx+rQ+068dxKaHC3Lt9 k7mDmcyElbqoG4Sobd0U+u776NAdhAhwHW3zevKxK/I+Yc7VV/xV860E0Xw+PJDM3Gz5 lsiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zsGUyzPwyU2D48eLQi5oVaEc8GeAsTJmPIqyMWCKDVc=; b=LFSqma8Po9zmgqxBLb0ozTURDo4Lcb7ydyyJE0tACU/hxeN7XZNEWEyV4eT/qon7bD RajKu53O1mVAH0wOdPMDkVSa6u+Rgacr8Qr8B5Ru2FiG/YN0NFo4KaGOs8yL5XZhQueY iPmuhD9/Bfs9IKji0EGxqJa4zaHLU6vetNawU7vLf/hetX+0UG4gQnEP/JTsuRPdviUc vUOYtF49zpkfzB+EFHumbkgsntO5TbKkB9byF8xezJ9N4BRFhX2NY3PEnfxdHZylh84c CbVnIvLGQl7Zc+ZYRC+WKL1SJyuz3iNNEm36rb275bovowAO7qH9+/GxR/xhRQtPp01t 6Ujw== X-Gm-Message-State: AOAM533a1zellqKVTZ50J/7FjVKAFSho3BYOeFuTRTm+9MP15IeVezLm xN16mxFuqnr2Q+BUg5Sxb/k= X-Received: by 2002:a17:902:a404:b0:14b:1100:aebc with SMTP id p4-20020a170902a40400b0014b1100aebcmr22765667plq.133.1646101585158; Mon, 28 Feb 2022 18:26:25 -0800 (PST) Received: from slim.das-security.cn ([103.84.139.53]) by smtp.gmail.com with ESMTPSA id 142-20020a621894000000b004dfc714b076sm15417821pfy.11.2022.02.28.18.26.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 18:26:24 -0800 (PST) From: Hangyu Hua To: gregkh@linuxfoundation.org Cc: stable@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, ben@decadent.org.uk, balbi@kernel.org, axboe@kernel.dk, mingo@kernel.org, jj251510319013@gmail.com, zsm@chromium.org, stern@rowland.harvard.edu, Hangyu Hua Subject: [PATCH 4.14 1/2] usb: gadget: don't release an existing dev->buf Date: Tue, 1 Mar 2022 10:26:07 +0800 Message-Id: <20220301022608.10950-2-hbh25y@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220301022608.10950-1-hbh25y@gmail.com> References: <20220301022608.10950-1-hbh25y@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 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 Cc: stable@vger.kernel.org #4.4+ --- 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