From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4FBFB168C2 for ; Mon, 8 May 2023 10:20:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C94DCC433EF; Mon, 8 May 2023 10:20:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1683541240; bh=bTownw0lLmAEW9KKrhaRE6LyTWM03ryZNH3lvWjfgeA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bo8XEpcIRMc8WaREGiOJEgORgrfldTRj2levlP4iAn0uU49WMsX7oKB1Lp58FpVya rwI/DAC6HnrfhGnmSVKVY8mxU5IREbgytpkO6uDhbf9WFKzjvWZzKAAxlpaKxoa7WA DOW19dzD+oxCGEVrt+g8+psChYQPjwO+m/Bv5OT0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Badhri Jagan Sridharan Subject: [PATCH 6.2 033/663] usb: gadget: udc: core: Prevent redundant calls to pullup Date: Mon, 8 May 2023 11:37:39 +0200 Message-Id: <20230508094429.534513106@linuxfoundation.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230508094428.384831245@linuxfoundation.org> References: <20230508094428.384831245@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Badhri Jagan Sridharan commit a3afbf5cc887fc3401f012fe629810998ed61859 upstream. 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. Fixes: 5a1da544e572 ("usb: gadget: core: do not try to disconnect gadget if it is not connected") Cc: stable@vger.kernel.org Signed-off-by: Badhri Jagan Sridharan Link: https://lore.kernel.org/r/20230407030741.3163220-2-badhri@google.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/udc/core.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/usb/gadget/udc/core.c +++ b/drivers/usb/gadget/udc/core.c @@ -676,6 +676,9 @@ static int usb_gadget_connect_locked(str goto out; } + if (gadget->connected) + goto out; + if (gadget->deactivated || !gadget->udc->started) { /* * If gadget is deactivated we only save new state.