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 3153624B28; Wed, 8 Apr 2026 18:18:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775672294; cv=none; b=DZB6NcisngZOmcyBKjVsYeliakHyzDBG/fr7Um8emkyd0KkQlgBAf3yePModeA+JHpRafc6IfuW9cRKJU6108CPLq71PHvYK+/fOcdQcBhC0uGBLeWfQvjQfzggQy2Biayx7QQGmYp977U0882yZS8P2qu0O9Hp8DFSCY48Nub8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775672294; c=relaxed/simple; bh=3+i8XTAfpLagAsEBkdV+Bw6Ek7UYN+9NLfCzpxG6aQM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uWLl7YKtJ1hqbuAYrLdpR4FnE+F6jr6Qu4wYXBQAp6b8iBQlNGX+IipllOo8tnKRwBO48Ssgo+WS0l18XiUK6fecjZa+EgvO36NNZX7FlQVDIZlWtASZa3h8QKc/OqDXPa/mSSOg3gUrWm8wyfZpb9X0SMUrl02z8IZMndyOoOc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=d69V4dWc; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="d69V4dWc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1370C19421; Wed, 8 Apr 2026 18:18:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1775672294; bh=3+i8XTAfpLagAsEBkdV+Bw6Ek7UYN+9NLfCzpxG6aQM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d69V4dWcvy5QRMF+yBLW6HQZoqIfXGeVVqs2jSlNx498Hk0cvUDr0QiojIAfhe0X8 QT+QcB/j8MeNZkT+VNyyGVusJ2lrCNbdkESX2So+HpjE7pKu9DZqydeQuyun1Pgldc Q3KoLh1KzAUJDb5Pz6Nn7/hpJ7jrgBDgQRj57i/Q= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable , Juno Choi Subject: [PATCH 6.1 231/312] usb: dwc2: gadget: Fix spin_lock/unlock mismatch in dwc2_hsotg_udc_stop() Date: Wed, 8 Apr 2026 20:02:28 +0200 Message-ID: <20260408175942.382075145@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260408175933.715315542@linuxfoundation.org> References: <20260408175933.715315542@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Juno Choi commit 9bb4b5ed7f8c4f95cc556bdf042b0ba2fa13557a upstream. dwc2_gadget_exit_clock_gating() internally calls call_gadget() macro, which expects hsotg->lock to be held since it does spin_unlock/spin_lock around the gadget driver callback invocation. However, dwc2_hsotg_udc_stop() calls dwc2_gadget_exit_clock_gating() without holding the lock. This leads to: - spin_unlock on a lock that is not held (undefined behavior) - The lock remaining held after dwc2_gadget_exit_clock_gating() returns, causing a deadlock when spin_lock_irqsave() is called later in the same function. Fix this by acquiring hsotg->lock before calling dwc2_gadget_exit_clock_gating() and releasing it afterwards, which satisfies the locking requirement of the call_gadget() macro. Fixes: af076a41f8a2 ("usb: dwc2: also exit clock_gating when stopping udc while suspended") Cc: stable Signed-off-by: Juno Choi Link: https://patch.msgid.link/20260324014910.2798425-1-juno.choi@lge.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc2/gadget.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -4605,7 +4605,9 @@ static int dwc2_hsotg_udc_stop(struct us /* Exit clock gating when driver is stopped. */ if (hsotg->params.power_down == DWC2_POWER_DOWN_PARAM_NONE && hsotg->bus_suspended && !hsotg->params.no_clock_gating) { + spin_lock_irqsave(&hsotg->lock, flags); dwc2_gadget_exit_clock_gating(hsotg, 0); + spin_unlock_irqrestore(&hsotg->lock, flags); } /* all endpoints should be shutdown */