[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20241127093547.3000267-1-mordan@ispras.ru>
Date: Wed, 27 Nov 2024 12:35:47 +0300
From: Vitalii Mordan <mordan@...ras.ru>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Vitalii Mordan <mordan@...ras.ru>,
Joel Stanley <joel@....id.au>,
Andrew Jeffery <andrew@...econstruct.com.au>,
Felipe Balbi <felipe.balbi@...ux.intel.com>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
linux-usb@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
linux-aspeed@...ts.ozlabs.org,
linux-kernel@...r.kernel.org,
Fedor Pchelkin <pchelkin@...ras.ru>,
Alexey Khoroshilov <khoroshilov@...ras.ru>,
Vadim Mutilin <mutilin@...ras.ru>,
stable@...r.kernel.org
Subject: [PATCH] usb: aspeed-vhub: fix call balance of vhub->clk handling routines
If the clock vhub->clk was not enabled in ast_vhub_probe,
vhub->clk will contain a non-NULL value leading to the clock being
incorrectly disabled later in ast_vhub_remove().
Use the devm_clk_get_enabled helper function to ensure proper call
balance for vhub->clk.
Found by Linux Verification Center (linuxtesting.org) with Klever.
Fixes: 7ecca2a4080c ("usb/gadget: Add driver for Aspeed SoC virtual hub")
Cc: stable@...r.kernel.org
Signed-off-by: Vitalii Mordan <mordan@...ras.ru>
---
drivers/usb/gadget/udc/aspeed-vhub/core.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/drivers/usb/gadget/udc/aspeed-vhub/core.c b/drivers/usb/gadget/udc/aspeed-vhub/core.c
index f60a019bb173..7566594fc447 100644
--- a/drivers/usb/gadget/udc/aspeed-vhub/core.c
+++ b/drivers/usb/gadget/udc/aspeed-vhub/core.c
@@ -277,9 +277,6 @@ static void ast_vhub_remove(struct platform_device *pdev)
VHUB_CTRL_PHY_RESET_DIS,
vhub->regs + AST_VHUB_CTRL);
- if (vhub->clk)
- clk_disable_unprepare(vhub->clk);
-
spin_unlock_irqrestore(&vhub->lock, flags);
if (vhub->ep0_bufs)
@@ -337,14 +334,10 @@ static int ast_vhub_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, vhub);
- vhub->clk = devm_clk_get(&pdev->dev, NULL);
+ vhub->clk = devm_clk_get_enabled(&pdev->dev, NULL);
if (IS_ERR(vhub->clk)) {
rc = PTR_ERR(vhub->clk);
- goto err;
- }
- rc = clk_prepare_enable(vhub->clk);
- if (rc) {
- dev_err(&pdev->dev, "Error couldn't enable clock (%d)\n", rc);
+ dev_err(&pdev->dev, "Error couldn't get and enable clock (%d)\n", rc);
goto err;
}
--
2.25.1
Powered by blists - more mailing lists