Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1738048rwl; Wed, 5 Apr 2023 23:54:50 -0700 (PDT) X-Google-Smtp-Source: AKy350bft9ArO4QbCUqU39zxMQxhyPrGH2YEAPOUbRKm63CRTgNZBC9RKnVxMo+kxKDiBFHjpacJ X-Received: by 2002:a17:902:e292:b0:1a2:1a33:6feb with SMTP id o18-20020a170902e29200b001a21a336febmr7722937plc.34.1680764090003; Wed, 05 Apr 2023 23:54:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680764089; cv=none; d=google.com; s=arc-20160816; b=pe9lLFd40Foc5/lKcQ8pZhvxz7dVhXxLYsWyy9Vn+TWLkN4AfVCXZuAEPX81Qc/a01 ycG2CQbU6XJrRZsF+D1l9BP+g5rfuyx/LUnmVq+dEvq3V0DakeLXhyywI+B3RtC8Tdma 8Y1+3KC7vZs9SA1DLYDdiAtPUMtMd0bmQC1kAGQzfGeiwirPu+E/4dViPAuI7JWwkqbv wxmvO5pOf0CjoaMFnzuwRVTJEPTCY16DpOBEDUIGq1ZFo2Hul/BmlTDSkVIGvmJPmmp4 Hq9yELC7pH6eXvC9m3OK3Hz/PsZbZ24jJyyf5PSRu+oXD00K6mG9NgGCfviY7wvLo0zc 3T+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=MR2uGYHr2XQbgshfGo1SsPwfCbCQRjTFchS5WzXQOLA=; b=CmgeTYXff0740InNJ4DqHxa/YgxyrdXk885Ii4V5V7EqtO8g/qCSBlWIhaMKAZC6qz r7954cdPKFvaAMgD/FD4Wqu4+m+8gkeMFQx5dF6Y51Nw54yI8qzBP5OF4UwnjEP9Ru7m WL4/S55OLM8lwuv7MgXO6+QeOh1E5rn2e942UNeV9eHLl0oENH6RpvcMxP/x5nE3gxJw pPoryFFl+UN0K4krbpI1pzAu1jFfvJPIGGJst+Bh0A6DZOKi4uAcq/rN4gzfkrYTX8re pfmM5sO7JMmxLiZQnUMEsqhyIcALf0bPKfKElO1W+yj3N4A54n4v0SUfQsPkc7/QZ098 7Mrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="H/HUkMo7"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kr16-20020a170903081000b001a1ba07911bsi907509plb.530.2023.04.05.23.54.38; Wed, 05 Apr 2023 23:54:49 -0700 (PDT) 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=@google.com header.s=20210112 header.b="H/HUkMo7"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234949AbjDFGg0 (ORCPT + 99 others); Thu, 6 Apr 2023 02:36:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235208AbjDFGgZ (ORCPT ); Thu, 6 Apr 2023 02:36:25 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E33B30CD for ; Wed, 5 Apr 2023 23:36:24 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id c18so36643739ple.11 for ; Wed, 05 Apr 2023 23:36:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680762984; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=MR2uGYHr2XQbgshfGo1SsPwfCbCQRjTFchS5WzXQOLA=; b=H/HUkMo7yH5xEcRprfpCq1CqZA9KAccmnFbceZgLqgyQbLuPaUxBeXB0a3xrn/shNg 2I8HZivgJ5n3vx6lPdOAXC4SLALjyH0VJ7cR4zsqyaTsLuktp7g4r0YoyDhbse9dZ3X8 Kxg8L3kCd2Z1suUT/NgCi/Xhi7U6lp1sfnvo0cR2UX6X2nm4DpYGUb+P+II+sbQ0UlLO XSXIOjBQlnRDgD71KZrIBcky4EjfA4n5BSZkt8c9ko9/KuUTdPRq9QGdMZx28PcCYId8 euEPhMgFvwTq3085sGkFmQnpnl9NQgvXQU5efE3J0AvEvPZcm8lFUmGVJHEXWJq9bSRQ V6tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680762984; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MR2uGYHr2XQbgshfGo1SsPwfCbCQRjTFchS5WzXQOLA=; b=NNtDUS0Etn9QRQpzPUTy9AtTNTa6VDBPX/ACtem7zmDIZ64+mYkGeYtIBb7b2SQy61 KQ56it9OfN5phLhfNvbsC5nitqcZEZWwnXyIIQk+9nBCHx/wtfLoTIgTtTNaGaIIPJz5 xroEeLm5OmoReLy7WYlHU4o8UL8ERrI1wxwYu8BaVXXUhy6Tajpa3xKxyL0WBOdkYyf5 +gUIAjzlbNWJJBWis02gHIuLZwcnW9SLkxCt7jZXGTCk1fm2Rf6mYlGaH9X7/MKEvaqj 25dfBXicdFyjodiqnraGkprMQemlFa6I8r2S9BUGwgD295p2JWgxJ2o/gF9VRGQG9fDE aRRg== X-Gm-Message-State: AAQBX9ciivI1Xem0QW99c7esdcFrIVNy+Cl6oP9DrgpFLNbFOEtg5OF2 AgpuaDuJQzWqZ2ydToLQLtVC24DQl0zW6X50Vw9VRg== X-Received: by 2002:a17:902:b693:b0:1a1:8f72:e9b with SMTP id c19-20020a170902b69300b001a18f720e9bmr3407891pls.7.1680762983590; Wed, 05 Apr 2023 23:36:23 -0700 (PDT) MIME-Version: 1.0 References: <20230405093133.1858140-1-badhri@google.com> <20230405093133.1858140-2-badhri@google.com> <2023040520-corned-recluse-d191@gregkh> In-Reply-To: <2023040520-corned-recluse-d191@gregkh> From: Badhri Jagan Sridharan Date: Wed, 5 Apr 2023 23:35:47 -0700 Message-ID: Subject: Re: [PATCH v1 2/2] usb: gadget: udc: core: Prevent redundant calls to pullup To: Greg KH Cc: stern@rowland.harvard.edu, colin.i.king@gmail.com, xuetao09@huawei.com, quic_eserrao@quicinc.com, water.zhangjiantao@huawei.com, peter.chen@freescale.com, balbi@ti.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-15.7 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,ENV_AND_HDR_SPF_MATCH, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=unavailable 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 On Wed, Apr 5, 2023 at 10:16=E2=80=AFAM Greg KH wrote: > > On Wed, Apr 05, 2023 at 09:31:33AM +0000, Badhri Jagan Sridharan wrote: > > usb_gadget_connect calls gadget->ops->pullup without > > checking whether gadget->connected was previously set. > > Make this symmetric to usb_gadget_disconnect by returning > > early if gadget->connected is already set. > > > > Cc: stable@vger.kernel.org > > > > Signed-off-by: Badhri Jagan Sridharan > > Fixes: 5a1da544e572 ("usb: gadget: core: do not try to disconnect gadge= t if it is not connected") > > Same changelog comment as before. Thanks for the feedback Greg ! Have fixed it in v2. > > > --- > > drivers/usb/gadget/udc/core.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/cor= e.c > > index 890f92cb6344..7eeaf7dbb350 100644 > > --- a/drivers/usb/gadget/udc/core.c > > +++ b/drivers/usb/gadget/udc/core.c > > @@ -708,6 +708,9 @@ int usb_gadget_connect(struct usb_gadget *gadget) > > goto out; > > } > > > > + if (gadget->connected) > > + goto out; > > + > > What prevents this connected value from changing right after you check > this? Nothing in V1 :) However, in v2, the newly introduced mutex guards gadget->connected as well. > > thanks, > > greg k-h