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 95B3F1DE2AC; Tue, 17 Dec 2024 17:27:27 +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=1734456447; cv=none; b=lyPZssSqkdRBkw5r/M/q5Wi5e3A87NG40piN6XrZsXcQMIM1S7pK8/0H1SFBZyEFKWxTrKPRdH100kxvp9gtAtCvQM33h42rrHaqHJ1oE2t9Qk+tKcwscYbpmDF0FalZdW1mCqRjrVcI7H4nbGd9+8FkI/LtJV6G59anqH5vhXU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734456447; c=relaxed/simple; bh=d1Qm9LrWYp4xvkzNcwQF1D4ieQ2ZjgObk14PoyCfqPA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KRv8vGYCbL1N1hAloPFdLkohOMQVC4hNDu/NGKgNxGIIPbCGOT/3/h7gTnW4tRQYqcUH7u93Ac9aVTrg0fermBMsT1wvzTG8a4Pv24BeYVk/i9dIjujDcrbkxO6amG6xqLm+ntWJTuaLqEtF8sXiaHww28NeWwkLaaAxaUSDvnU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=FXxsyZlT; 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="FXxsyZlT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2070BC4CED3; Tue, 17 Dec 2024 17:27:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1734456447; bh=d1Qm9LrWYp4xvkzNcwQF1D4ieQ2ZjgObk14PoyCfqPA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FXxsyZlTOxgEk5ObEFEVAyDeQgM1vS75JfeEtuOV/mjA20gOSNv1MNzgRqemIoM4d 9sSYyOqwq//eR5dbtDnWIun6t/pZnvDMJ6BPdtyEOVasJycQdOyId1LZnPRFOlKNeU HGLUNluaTgO8RlwxBLuMPgqB5tE3oX0+tsRsONa8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Vitalii Mordan , Alan Stern Subject: [PATCH 6.12 046/172] usb: ehci-hcd: fix call balance of clocks handling routines Date: Tue, 17 Dec 2024 18:06:42 +0100 Message-ID: <20241217170548.172951484@linuxfoundation.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241217170546.209657098@linuxfoundation.org> References: <20241217170546.209657098@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Vitalii Mordan commit 97264eaaba0122a5b7e8ddd7bf4ff3ac57c2b170 upstream. If the clocks priv->iclk and priv->fclk were not enabled in ehci_hcd_sh_probe, they should not be disabled in any path. Conversely, if they was enabled in ehci_hcd_sh_probe, they must be disabled in all error paths to ensure proper cleanup. Found by Linux Verification Center (linuxtesting.org) with Klever. Fixes: 63c845522263 ("usb: ehci-hcd: Add support for SuperH EHCI.") Cc: stable@vger.kernel.org # ff30bd6a6618: sh: clk: Fix clk_enable() to return 0 on NULL clk Signed-off-by: Vitalii Mordan Reviewed-by: Alan Stern Link: https://lore.kernel.org/r/20241121114700.2100520-1-mordan@ispras.ru Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/ehci-sh.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) --- a/drivers/usb/host/ehci-sh.c +++ b/drivers/usb/host/ehci-sh.c @@ -119,8 +119,12 @@ static int ehci_hcd_sh_probe(struct plat if (IS_ERR(priv->iclk)) priv->iclk = NULL; - clk_enable(priv->fclk); - clk_enable(priv->iclk); + ret = clk_enable(priv->fclk); + if (ret) + goto fail_request_resource; + ret = clk_enable(priv->iclk); + if (ret) + goto fail_iclk; ret = usb_add_hcd(hcd, irq, IRQF_SHARED); if (ret != 0) { @@ -136,6 +140,7 @@ static int ehci_hcd_sh_probe(struct plat fail_add_hcd: clk_disable(priv->iclk); +fail_iclk: clk_disable(priv->fclk); fail_request_resource: