linux-phy.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] phy: qualcomm: Check NULL ptr on lvts_data in qcom_ipq806x_usb_phy_probe()
  2024-08-21 14:50 ` Bjorn Andersson
@ 2024-08-20 21:50   ` Christian Marangi
  0 siblings, 0 replies; 3+ messages in thread
From: Christian Marangi @ 2024-08-20 21:50 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Ma Ke, vkoul, kishon, agross, linux-arm-msm, linux-phy,
	linux-kernel, stable

On Wed, Aug 21, 2024 at 09:50:27AM -0500, Bjorn Andersson wrote:
> On Wed, Aug 21, 2024 at 09:10:42PM GMT, Ma Ke wrote:
> > of_device_get_match_data() can return NULL if of_match_device failed, and
> > the pointer 'data' was dereferenced without checking against NULL. Add
> > checking of pointer 'data' in qcom_ipq806x_usb_phy_probe().
> 
> How do you create the platform_device such that this happens?
>

I have the same question and this sounds like warning produced by
automated checks of some sort... (and these kind of patch are suspicious
given what happens in the last few years)

In practice this can never happen... of_match_device can't fail as it's
called only if a matching compatible is found hence the thing MUST be
present BEFORE probe is even called.

> 
> > 
> > Cc: stable@vger.kernel.org
> > Fixes: ef19b117b834 ("phy: qualcomm: add qcom ipq806x dwc usb phy driver")
> > Signed-off-by: Ma Ke <make24@iscas.ac.cn>
> > ---
> >  drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c b/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
> > index 06392ed7c91b..9b9fd9c1b1f7 100644
> > --- a/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
> > +++ b/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
> > @@ -492,6 +492,8 @@ static int qcom_ipq806x_usb_phy_probe(struct platform_device *pdev)
> >  		return -ENOMEM;
> >  
> >  	data = of_device_get_match_data(&pdev->dev);
> > +	if (!data)
> > +		return -ENODEV;
> >  
> >  	phy_dwc3->dev = &pdev->dev;
> >  
> > -- 
> > 2.25.1
> > 
> > 

-- 
	Ansuel

-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] phy: qualcomm: Check NULL ptr on lvts_data in qcom_ipq806x_usb_phy_probe()
@ 2024-08-21 13:10 Ma Ke
  2024-08-21 14:50 ` Bjorn Andersson
  0 siblings, 1 reply; 3+ messages in thread
From: Ma Ke @ 2024-08-21 13:10 UTC (permalink / raw)
  To: vkoul, kishon, make24, agross, ansuelsmth
  Cc: linux-arm-msm, linux-phy, linux-kernel, stable

of_device_get_match_data() can return NULL if of_match_device failed, and
the pointer 'data' was dereferenced without checking against NULL. Add
checking of pointer 'data' in qcom_ipq806x_usb_phy_probe().

Cc: stable@vger.kernel.org
Fixes: ef19b117b834 ("phy: qualcomm: add qcom ipq806x dwc usb phy driver")
Signed-off-by: Ma Ke <make24@iscas.ac.cn>
---
 drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c b/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
index 06392ed7c91b..9b9fd9c1b1f7 100644
--- a/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
+++ b/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
@@ -492,6 +492,8 @@ static int qcom_ipq806x_usb_phy_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	data = of_device_get_match_data(&pdev->dev);
+	if (!data)
+		return -ENODEV;
 
 	phy_dwc3->dev = &pdev->dev;
 
-- 
2.25.1


-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] phy: qualcomm: Check NULL ptr on lvts_data in qcom_ipq806x_usb_phy_probe()
  2024-08-21 13:10 [PATCH] phy: qualcomm: Check NULL ptr on lvts_data in qcom_ipq806x_usb_phy_probe() Ma Ke
@ 2024-08-21 14:50 ` Bjorn Andersson
  2024-08-20 21:50   ` Christian Marangi
  0 siblings, 1 reply; 3+ messages in thread
From: Bjorn Andersson @ 2024-08-21 14:50 UTC (permalink / raw)
  To: Ma Ke
  Cc: vkoul, kishon, agross, ansuelsmth, linux-arm-msm, linux-phy,
	linux-kernel, stable

On Wed, Aug 21, 2024 at 09:10:42PM GMT, Ma Ke wrote:
> of_device_get_match_data() can return NULL if of_match_device failed, and
> the pointer 'data' was dereferenced without checking against NULL. Add
> checking of pointer 'data' in qcom_ipq806x_usb_phy_probe().

How do you create the platform_device such that this happens?

Regards,
Bjorn

> 
> Cc: stable@vger.kernel.org
> Fixes: ef19b117b834 ("phy: qualcomm: add qcom ipq806x dwc usb phy driver")
> Signed-off-by: Ma Ke <make24@iscas.ac.cn>
> ---
>  drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c b/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
> index 06392ed7c91b..9b9fd9c1b1f7 100644
> --- a/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
> +++ b/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
> @@ -492,6 +492,8 @@ static int qcom_ipq806x_usb_phy_probe(struct platform_device *pdev)
>  		return -ENOMEM;
>  
>  	data = of_device_get_match_data(&pdev->dev);
> +	if (!data)
> +		return -ENODEV;
>  
>  	phy_dwc3->dev = &pdev->dev;
>  
> -- 
> 2.25.1
> 
> 

-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-08-21 17:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-21 13:10 [PATCH] phy: qualcomm: Check NULL ptr on lvts_data in qcom_ipq806x_usb_phy_probe() Ma Ke
2024-08-21 14:50 ` Bjorn Andersson
2024-08-20 21:50   ` Christian Marangi

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).