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 mordan@ispras.ru --- drivers/usb/host/ehci-sh.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/host/ehci-sh.c b/drivers/usb/host/ehci-sh.c index d31d9506e41a..77460aac6dbd 100644 --- 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 platform_device *pdev) 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 platform_device *pdev)
fail_add_hcd: clk_disable(priv->iclk); +fail_iclk: clk_disable(priv->fclk);
fail_request_resource:
On Thu, Nov 21, 2024 at 02:47:00PM +0300, Vitalii Mordan wrote:
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 mordan@ispras.ru
Reviewed-by: Alan Stern stern@rowland.harvard.edu
drivers/usb/host/ehci-sh.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/host/ehci-sh.c b/drivers/usb/host/ehci-sh.c index d31d9506e41a..77460aac6dbd 100644 --- 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 platform_device *pdev) 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 platform_device *pdev) fail_add_hcd: clk_disable(priv->iclk); +fail_iclk: clk_disable(priv->fclk); fail_request_resource: -- 2.25.1
On Thu, 21. Nov 14:47, Vitalii Mordan wrote:
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 mordan@ispras.ru
The current patch was added to stable kernels lacking the necessary prerequisite ff30bd6a6618 ("sh: clk: Fix clk_enable() to return 0 on NULL clk") which is specified in Cc:stable tag of the commit description per stable kernels documentation [1].
[1]: https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html#opti...
Could you please cherry-pick ff30bd6a6618 ("sh: clk: Fix clk_enable() to return 0 on NULL clk") to 6.1.y, 5.15.y, 5.10.y and 5.4.y ? It applies cleanly.
Thanks!
drivers/usb/host/ehci-sh.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/host/ehci-sh.c b/drivers/usb/host/ehci-sh.c index d31d9506e41a..77460aac6dbd 100644 --- 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 platform_device *pdev) 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 platform_device *pdev) fail_add_hcd: clk_disable(priv->iclk); +fail_iclk: clk_disable(priv->fclk); fail_request_resource: -- 2.25.1
[ Sasha's backport helper bot ]
Hi,
Found matching upstream commit: 97264eaaba0122a5b7e8ddd7bf4ff3ac57c2b170
Status in newer kernel trees: 6.12.y | Present (different SHA1: 0967e8e734b8)
Note: The patch differs from the upstream commit: --- Failed to apply patch cleanly, falling back to interdiff... ---
Results of testing on various branches:
| Branch | Patch Apply | Build Test | |---------------------------|-------------|------------| | stable/linux-6.12.y | Failed | N/A | | stable/linux-6.6.y | Failed | N/A | | stable/linux-6.1.y | Failed | N/A | | stable/linux-5.15.y | Failed | N/A | | stable/linux-5.10.y | Failed | N/A | | stable/linux-5.4.y | Failed | N/A |
Hello,
A required dependency commit is missing, as noted by Fedor Pchelkin:
The current patch was added to stable kernels lacking the necessary prerequisite ff30bd6a6618 ("sh: clk: Fix clk_enable() to return 0 on NULL clk") which is specified in Cc:stable tag of the commit description per stable kernels documentation [1]. [1]: https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html#opti... Could you please cherry-pick ff30bd6a6618 ("sh: clk: Fix clk_enable() to return 0 on NULL clk") to 6.1.y, 5.15.y, 5.10.y and 5.4.y ? It applies cleanly. Thanks!
On Tue, 24. Dec 14:56, mordan@ispras.ru wrote:
Hello,
A required dependency commit is missing, as noted by Fedor Pchelkin:
Hmm... Vitalii, this was added to stable-queue by Greg KH after I've posted the request, so everything is OK now.
https://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git/comm... https://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git/comm... https://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git/comm...
The current patch was added to stable kernels lacking the necessary prerequisite ff30bd6a6618 ("sh: clk: Fix clk_enable() to return 0 on NULL clk") which is specified in Cc:stable tag of the commit description per stable kernels documentation [1]. [1]: https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html#opti... Could you please cherry-pick ff30bd6a6618 ("sh: clk: Fix clk_enable() to return 0 on NULL clk") to 6.1.y, 5.15.y, 5.10.y and 5.4.y ? It applies cleanly. Thanks!
linux-stable-mirror@lists.linaro.org