From: Alan Stern <stern@rowland.harvard.edu>
To: Evgeny Novikov <novikov@ispras.ru>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Andrew Lunn <andrew@lunn.ch>,
Mike Turquette <mturquette@linaro.org>,
Kirill Shilimanov <kirill.shilimanov@huawei.com>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
ldv-project@linuxtesting.org
Subject: Re: [PATCH] usb: ehci-orion: Handle errors of clk_prepare_enable() in probe
Date: Wed, 25 Aug 2021 13:29:37 -0400 [thread overview]
Message-ID: <20210825172937.GD192480@rowland.harvard.edu> (raw)
In-Reply-To: <20210825170902.11234-1-novikov@ispras.ru>
On Wed, Aug 25, 2021 at 08:09:02PM +0300, Evgeny Novikov wrote:
> ehci_orion_drv_probe() did not account for possible errors of
> clk_prepare_enable() that in particular could cause invocation of
> clk_disable_unprepare() on clocks that were not prepared/enabled yet,
> e.g. in remove or on handling errors of usb_add_hcd() in probe. Though,
> there were several patches fixing different issues with clocks in this
> driver, they did not solve this problem.
>
> Add handling of errors of clk_prepare_enable() in ehci_orion_drv_probe()
> to avoid calls of clk_disable_unprepare() without previous successful
> invocation of clk_prepare_enable().
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Fixes: 8c869edaee07 ("ARM: Orion: EHCI: Add support for enabling clocks")
> Signed-off-by: Evgeny Novikov <novikov@ispras.ru>
> Co-developed-by: Kirill Shilimanov <kirill.shilimanov@huawei.com>
> Signed-off-by: Kirill Shilimanov <kirill.shilimanov@huawei.com>
> ---
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Do you intend to submit patches for the other EHCI drivers that don't
check for errors in clk_prepare_enable()? It looks like
ehci-atmel.c, ehci-mv.c, and ehci-spear.c all need some attention.
The same is true for a bunch of the OHCI drivers: ohci-at91.c,
ohci-exynos.c, ohci-s3c2410.c, and ohci-spear.c.
Didn't the Linux Driver Verification project identify this problem in
all of these drivers?
Alan Stern
> drivers/usb/host/ehci-orion.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c
> index a319b1df3011..3626758b3e2a 100644
> --- a/drivers/usb/host/ehci-orion.c
> +++ b/drivers/usb/host/ehci-orion.c
> @@ -264,8 +264,11 @@ static int ehci_orion_drv_probe(struct platform_device *pdev)
> * the clock does not exists.
> */
> priv->clk = devm_clk_get(&pdev->dev, NULL);
> - if (!IS_ERR(priv->clk))
> - clk_prepare_enable(priv->clk);
> + if (!IS_ERR(priv->clk)) {
> + err = clk_prepare_enable(priv->clk);
> + if (err)
> + goto err_put_hcd;
> + }
>
> priv->phy = devm_phy_optional_get(&pdev->dev, "usb");
> if (IS_ERR(priv->phy)) {
> @@ -311,6 +314,7 @@ static int ehci_orion_drv_probe(struct platform_device *pdev)
> err_dis_clk:
> if (!IS_ERR(priv->clk))
> clk_disable_unprepare(priv->clk);
> +err_put_hcd:
> usb_put_hcd(hcd);
> err:
> dev_err(&pdev->dev, "init %s fail, %d\n",
> --
> 2.26.2
>
next prev parent reply other threads:[~2021-08-25 17:29 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-25 17:09 [PATCH] usb: ehci-orion: Handle errors of clk_prepare_enable() in probe Evgeny Novikov
2021-08-25 17:29 ` Alan Stern [this message]
2021-08-26 13:30 ` Evgeny Novikov
2021-08-26 15:24 ` Alan Stern
2021-08-26 16:26 ` Evgeny Novikov
2021-08-27 11:51 ` Dan Carpenter
2021-08-28 10:37 ` Evgeny Novikov
2021-08-28 10:47 ` Evgeny Novikov
2021-08-28 15:11 ` Alan Stern
2021-08-25 17:33 ` Andrew Lunn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210825172937.GD192480@rowland.harvard.edu \
--to=stern@rowland.harvard.edu \
--cc=andrew@lunn.ch \
--cc=gregkh@linuxfoundation.org \
--cc=kirill.shilimanov@huawei.com \
--cc=ldv-project@linuxtesting.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mturquette@linaro.org \
--cc=novikov@ispras.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).