Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1723744rwl; Wed, 5 Apr 2023 23:34:36 -0700 (PDT) X-Google-Smtp-Source: AKy350bOklPYDJ7HGjKWcLJJntbtRKfTtLTcPJkYUFInCdgIlL39ZcCfCOxoLe+S3JQtER9MMG9k X-Received: by 2002:a17:902:dacf:b0:1a1:f95a:24f2 with SMTP id q15-20020a170902dacf00b001a1f95a24f2mr11416235plx.19.1680762876621; Wed, 05 Apr 2023 23:34:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680762876; cv=none; d=google.com; s=arc-20160816; b=LFikPuA9Ill/VLmW39qlPeCX9nLD510cg6glts7ffgZknccGY8IRIvgN6Xu6mWjAik qeUPjgEU3WFjLHhBVS8L8nfk1th2lM0ebAuyipCcBlU5LXS9pwuLKoT5hccTmftkCwVj 8Ex6y7LolU1zLUaOlT8w4C5pHIbESPu9yjdJzSE5lTPokC4dCwJdNsPlXyDoqwT3XnBd CorSl4Thz8t2CTxBcsKlEZukxKbRjyCbjebXQDi7Io6Se4t4b+5DnygcizNjU9jxUbR6 ZF9I9wgiWLxkqV3WqBgb/SvQIrgK3SzSHPPHvsXQCX1Ebm1DRSfDakWoCwBzYb/45fOg VBxw== 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=CWGJHZGuLO/YuuWqIvXgJSP33m7hrVTQlRsDLK3HYVU=; b=s9S+XnOGJ6+oXX2m1V8juTqqGKCE6i89j52VolGTp6zqSBvZNToyMHMiRyZKivrx3P v+OG5XNMmRFpKmC8o1LPj5GxdP8FvImOUnJX35mKD188AAep9nJ7lXLFFI2zh5rjK98b /79fZb3qrZ4bGaNNJ9b6zUOALiPoYwBZBO558p2xxiTSjHfnqD66Gficb+imbu49+sWG GuAedRW0TBUycXtvjwA5xbS1x6wlTlaAvu6jyD/CSb0WJyNWodQRdf0JhAxVIDT26BrQ gdbTBpS2MXEBYq5qhaKrOMQ9iaRZZ8HxTSIG4rmjlwfQK9sCHzOvlf/pT463NpNuU4ty E1KA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=tbNME8VJ; 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 w6-20020a170902d70600b0019937768786si933401ply.290.2023.04.05.23.34.24; Wed, 05 Apr 2023 23:34:36 -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=tbNME8VJ; 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 S235061AbjDFG3b (ORCPT + 99 others); Thu, 6 Apr 2023 02:29:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235394AbjDFG3W (ORCPT ); Thu, 6 Apr 2023 02:29:22 -0400 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B19BA26D for ; Wed, 5 Apr 2023 23:29:17 -0700 (PDT) Received: by mail-pf1-x430.google.com with SMTP id ce4so12091617pfb.1 for ; Wed, 05 Apr 2023 23:29:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680762556; 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=CWGJHZGuLO/YuuWqIvXgJSP33m7hrVTQlRsDLK3HYVU=; b=tbNME8VJ9ofUZcpyvEsVPMkIkRCP/8IgJy7M4DQOwyIqjtYMTaQ9TRonfmLKOFfQ4v 9r7lA3W3ca/Ir8arbXVJhSHoPkqsi2OldovZCyA9k9ZgFpVws39W5YhJW41uR30kzL51 bHZw3Oe3dfE8mQFtkTBqG1Ci2Tx2EPBOjorhdyrJdKrO64iXUvBgViEJ6NHFDBHaZfJM 4FrylSweuq9evN+DpmFcGZBnP3C8x8I1NlHuW1ZXw015rjx9d3UKsaFbkTY3Xz1kOTyv 7PoCynrYx0Y882iC+V/qGu/Mm3AhqKFV1kRrhnslVfrYKf6Wf/uYlxHc4UclV8uXueRp O/FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680762556; 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=CWGJHZGuLO/YuuWqIvXgJSP33m7hrVTQlRsDLK3HYVU=; b=AUzrD6jMcseV6nZT9hR6k5PIlfSt+9xgkwd1LMki26tXtIzaPsh+/zBJ3q6HoPyxga ZmkNj6IDoaAdjOOIeKNB0Ku3YQukeUhDEomsMuSACQk2sU0GFEduQSXdgR+YEHtUWm9I eWPfTYELCsc0ZjYVzp7vzO3/0Z+8TqzXzD0ou8WFGFjYIJoeRKL1FpoVmNIK5yGm+V8o jy56/aUN/+UxVHYnHcmQBZDYUIOyF86tDjTI9IXHGlAC8gTrUnOLhf6YGDeVSroyyBVR dA8cfE/gi2Qfd77SiMl3wWGKt9kdZ5q/lGCFIR9s/0d5LlIDWsIQj7zPev7gIKKgPWVP eXMw== X-Gm-Message-State: AAQBX9fFQR0jXOodKZ8eQ25bLMoTqXVvHYy8F21b1wUG5imImjJ9LkTd ShTi8tGZI8sf2SkJkYotOdpgxx7Exmd4ZriPoLEpGA== X-Received: by 2002:a63:551d:0:b0:507:4737:cdb5 with SMTP id j29-20020a63551d000000b005074737cdb5mr2749471pgb.8.1680762556446; Wed, 05 Apr 2023 23:29:16 -0700 (PDT) MIME-Version: 1.0 References: <20230406061905.2460827-1-badhri@google.com> <20230406061905.2460827-2-badhri@google.com> In-Reply-To: <20230406061905.2460827-2-badhri@google.com> From: Badhri Jagan Sridharan Date: Wed, 5 Apr 2023 23:28:40 -0700 Message-ID: Subject: Re: [PATCH v1 2/2] usb: gadget: udc: core: Prevent redundant calls to pullup 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 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 Apologies resent V1 again instead of V2. Have sent V2 for real. On Wed, Apr 5, 2023 at 11:19=E2=80=AFPM 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 gadget = if it is not connected") > --- > 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 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; > + > if (gadget->deactivated) { > /* > * If gadget is deactivated we only save new state. > -- > 2.40.0.348.gf938b09366-goog >