Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1717482rwl; Wed, 5 Apr 2023 23:26:59 -0700 (PDT) X-Google-Smtp-Source: AKy350YM3G6Pin7aLWwa84ZI9iTQlRBj4gNnG1P4B2bu9I3Lk9Cvc8z40ucXTjFtKn0YTwpqj4WB X-Received: by 2002:a17:903:22cb:b0:19f:2b42:5d01 with SMTP id y11-20020a17090322cb00b0019f2b425d01mr11676509plg.9.1680762419562; Wed, 05 Apr 2023 23:26:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680762419; cv=none; d=google.com; s=arc-20160816; b=PunSvO4LZhpbEawqL7ufv94eO//FO2zfHmob/yUqYTaZNKEGouY6JuMZmyO7wtovQe NAxvyS/FQZJHo267mOPW7BzDTDkNbRCFhW9SyRJEuXZH6wNu+slsQOVEJCqgJ7ZbMmGl NBn3Swnhi1rvqdc6tWZBT4ruQJstp4QsV7CHKGXu5NK7VyIR/74jQ4eLB27RA8e48iQS 6f+49Jl1jLCbaI4xkys+y5Ggh43vG/88WbAOyO82db1XUZNWNR/RnVqp8upztFqPnJ1O YCmYOunhfFVbBjrfqldGih6MBXX4mZ3283wbWFHawjgw9ED4RfpKDpVcmf0Swf6z/hV6 89lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=XOlLzWfgNnbnW7p6oIl7dNBSN44VuNGNPEzVTHeVNvI=; b=UuK9WwsoJt3VbO2g/V8VhRiFu7YfnhYjAKZ0PZdUjIKD5SxMHTOeFfomiBnMVtLHsJ ivFmNHuxpJfARWxfyTaYQayScf4sInTSVLy4nrP2Hs4XGv/FWWjodX2qge8oG1pukQDM brdqHDHZLumZeX75yv5Lt8SGZU654q8A0eG5jwZQvkG5Gl99WEeh6hdCuKBjPAxTc3y+ fBI0BuYkA07Jai6h1eUFXNwIaqTnDRBM3YmBon3OSzbGvM0xlp5vOAmSVri4ppuK6l4R 3QhAv30QXHTEKn2pOcElCsFiUhHWHJgpIwLYJHmZS6OAmtd4oV+Zs1AN2le2c+YA5Rj5 D/KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=DhEC60Ow; 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 n19-20020a170902d0d300b001a1fc721c0csi926181pln.116.2023.04.05.23.26.48; Wed, 05 Apr 2023 23:26:59 -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=DhEC60Ow; 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 S232605AbjDFGZ6 (ORCPT + 99 others); Thu, 6 Apr 2023 02:25:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235254AbjDFGZ4 (ORCPT ); Thu, 6 Apr 2023 02:25:56 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EB149027 for ; Wed, 5 Apr 2023 23:25:54 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-545e529206eso319490557b3.9 for ; Wed, 05 Apr 2023 23:25:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680762353; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=XOlLzWfgNnbnW7p6oIl7dNBSN44VuNGNPEzVTHeVNvI=; b=DhEC60Ow8vPo7JguqG0tasYKWhlNR5us0qs3pPUwuVjtYwga24d+eHKIyJUuxHP8/C mMoWhG6yZNsZjWCJ/hm88BJ0JjGjx2rzO7NXlC7W0S2Duh4RR1Oy9wc3BFxm/eKP7seu DLd4Xs4bQ5MIlQ4uR056N6YH9lIdLWC4z3bIeCUY8xxTWI5gRm1O0tXRDBVXEcXq1XNH Y2FHXHYgQNIJp9eSvjAIpegVdlmn1drVcN4dKHlRFjYWaC7S+SAa53jtLrx8oy2XH+mD wWb3TiBEFkib0WdW3AFnNpU8L5h/H2bs8rIT+cDvR6hu11qQAhv+PMc0AndApEDkr0ba SeAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680762353; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=XOlLzWfgNnbnW7p6oIl7dNBSN44VuNGNPEzVTHeVNvI=; b=Z8BaUD1Yjsf851xrZlRLG/PVYOEuf09sEuzP9yBT4e/rx5+gSVRv6CEnY4pBNeYyfD A/uIgdVdBxcSC1+kmXPtxDK8bcvEEUtZibWOEFtVnHw9NPcDu2n+/AeiS+r1KzFhaZ9K IjqjadzjwqFoKM7y8k2dEKnwaz5DQS8CROHPc22oTfh3MP5C+ku/a13DBKWvBFTuCzb5 NEIZGrrH8+Kr1SpEPwxU4ZV46QtKZV3enLznge+/atrLAfp+ODBhoVUkW2o0EMdNDRaZ liGy19Mbp0A6hp+FW2oDeZoxQB8Ee0yMazH+gOwM7k90Dle2B5UVx4bmf553SgjB+jnM rlUA== X-Gm-Message-State: AAQBX9f30FdwLG+Bbn+u0tsUqbtphprOcntmEPSfPPJ7GuHN5wCXDlUl 7Kmm5p3nw3ou9P35yGqTD1cSuJmEBh0= X-Received: from badhri.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:6442]) (user=badhri job=sendgmr) by 2002:a05:690c:72c:b0:52f:184a:da09 with SMTP id bt12-20020a05690c072c00b0052f184ada09mr3270357ywb.2.1680762353705; Wed, 05 Apr 2023 23:25:53 -0700 (PDT) Date: Thu, 6 Apr 2023 06:25:49 +0000 In-Reply-To: <20230406062549.2461917-1-badhri@google.com> Mime-Version: 1.0 References: <20230406062549.2461917-1-badhri@google.com> X-Mailer: git-send-email 2.40.0.348.gf938b09366-goog Message-ID: <20230406062549.2461917-2-badhri@google.com> Subject: [PATCH v2 2/2] usb: gadget: udc: core: Prevent redundant calls to pullup From: Badhri Jagan Sridharan To: gregkh@linuxfoundation.org, 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 Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Badhri Jagan Sridharan Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.7 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_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 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 Fixes: 5a1da544e572 ("usb: gadget: core: do not try to disconnect gadget if it is not connected") Signed-off-by: Badhri Jagan Sridharan --- * Fixed commit message comments. --- 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/core.c index 41d3a1998cff..f18a5ef7e6ab 100644 --- a/drivers/usb/gadget/udc/core.c +++ b/drivers/usb/gadget/udc/core.c @@ -702,6 +702,9 @@ int usb_gadget_connect_locked(struct usb_gadget *gadget) goto out; } + if (gadget->connected) + goto out; + if (gadget->deactivated || !gadget->udc->started) { /* * If gadget is deactivated we only save new state. -- 2.40.0.348.gf938b09366-goog