From: Peter Chen <peter.chen@kernel.org>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Fabio Estevam <festevam@gmail.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
NXP Linux Team <linux-imx@nxp.com>,
Frieder Schrempf <frieder.schrempf@kontron.de>,
linux-usb@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] usb: chipidea: ci_hdrc_imx: fix potential error pointer dereference in probe
Date: Sat, 20 Nov 2021 14:16:24 +0800 [thread overview]
Message-ID: <20211120061624.GA3874@Peter> (raw)
In-Reply-To: <20211117074923.GF5237@kili>
On 21-11-17 10:49:23, Dan Carpenter wrote:
> If the first call to devm_usb_get_phy_by_phandle(dev, "fsl,usbphy", 0)
> fails with something other than -ENODEV then it leads to an error
> pointer dereference. For those errors we should just jump directly to
> the error handling.
>
> Fixes: 8253a34bfae3 ("usb: chipidea: ci_hdrc_imx: Also search for 'phys' phandle")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> drivers/usb/chipidea/ci_hdrc_imx.c | 18 +++++++++---------
> 1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
> index f1d100671ee6..097142ffb184 100644
> --- a/drivers/usb/chipidea/ci_hdrc_imx.c
> +++ b/drivers/usb/chipidea/ci_hdrc_imx.c
> @@ -420,15 +420,15 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
> data->phy = devm_usb_get_phy_by_phandle(dev, "fsl,usbphy", 0);
> if (IS_ERR(data->phy)) {
> ret = PTR_ERR(data->phy);
> - if (ret == -ENODEV) {
> - data->phy = devm_usb_get_phy_by_phandle(dev, "phys", 0);
> - if (IS_ERR(data->phy)) {
> - ret = PTR_ERR(data->phy);
> - if (ret == -ENODEV)
> - data->phy = NULL;
> - else
> - goto err_clk;
> - }
> + if (ret != -ENODEV)
> + goto err_clk;
> + data->phy = devm_usb_get_phy_by_phandle(dev, "phys", 0);
> + if (IS_ERR(data->phy)) {
> + ret = PTR_ERR(data->phy);
> + if (ret == -ENODEV)
> + data->phy = NULL;
> + else
> + goto err_clk;
> }
> }
>
> --
> 2.20.1
>
Acked-by: Peter Chen <peter.chen@kernel.org>
--
Thanks,
Peter Chen
prev parent reply other threads:[~2021-11-20 6:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-17 7:49 [PATCH] usb: chipidea: ci_hdrc_imx: fix potential error pointer dereference in probe Dan Carpenter
2021-11-20 6:16 ` Peter Chen [this message]
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=20211120061624.GA3874@Peter \
--to=peter.chen@kernel.org \
--cc=dan.carpenter@oracle.com \
--cc=festevam@gmail.com \
--cc=frieder.schrempf@kontron.de \
--cc=gregkh@linuxfoundation.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=kernel@pengutronix.de \
--cc=linux-imx@nxp.com \
--cc=linux-usb@vger.kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
/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