* [PATCH] xhci: host: potential NULL dereference in xhci_generic_plat_probe()
@ 2023-02-09 13:43 Dan Carpenter
2023-02-10 16:45 ` Arnd Bergmann
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2023-02-09 13:43 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Mathias Nyman, Greg Kroah-Hartman, linux-usb, kernel-janitors
It's possible to exit the loop with "sysdev" set to NULL. In that
case we should use "&pdev->dev".
Fixes: ec5499d338ec ("xhci: split out rcar/rz support from xhci-plat.c")
Signed-off-by: Dan Carpenter <error27@gmail.com>
---
drivers/usb/host/xhci-plat.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index cd17ccab6e00..b9f9625467d6 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -368,6 +368,9 @@ static int xhci_generic_plat_probe(struct platform_device *pdev)
#endif
}
+ if (!sysdev)
+ sysdev = &pdev->dev;
+
if (WARN_ON(!sysdev->dma_mask)) {
/* Platform did not initialize dma_mask */
ret = dma_coerce_mask_and_coherent(sysdev, DMA_BIT_MASK(64));
--
2.35.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] xhci: host: potential NULL dereference in xhci_generic_plat_probe()
2023-02-09 13:43 [PATCH] xhci: host: potential NULL dereference in xhci_generic_plat_probe() Dan Carpenter
@ 2023-02-10 16:45 ` Arnd Bergmann
0 siblings, 0 replies; 2+ messages in thread
From: Arnd Bergmann @ 2023-02-10 16:45 UTC (permalink / raw)
To: Dan Carpenter
Cc: Mathias Nyman, Greg Kroah-Hartman, linux-usb, kernel-janitors
On Thu, Feb 9, 2023, at 14:43, Dan Carpenter wrote:
> It's possible to exit the loop with "sysdev" set to NULL. In that
> case we should use "&pdev->dev".
>
> Fixes: ec5499d338ec ("xhci: split out rcar/rz support from xhci-plat.c")
> Signed-off-by: Dan Carpenter <error27@gmail.com>
Thanks for the fix!
I think this doesn't happen in practice because the loop should
always find a firmware or PCI owned device, but it is clearly better
to keep the original behavior from before my patch to be on the
safe side here.
Acked-by: Arnd Bergmann <arnd@arndb.de>
> drivers/usb/host/xhci-plat.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> index cd17ccab6e00..b9f9625467d6 100644
> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -368,6 +368,9 @@ static int xhci_generic_plat_probe(struct
> platform_device *pdev)
> #endif
> }
>
> + if (!sysdev)
> + sysdev = &pdev->dev;
> +
> if (WARN_ON(!sysdev->dma_mask)) {
> /* Platform did not initialize dma_mask */
> ret = dma_coerce_mask_and_coherent(sysdev, DMA_BIT_MASK(64));
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-02-10 16:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-09 13:43 [PATCH] xhci: host: potential NULL dereference in xhci_generic_plat_probe() Dan Carpenter
2023-02-10 16:45 ` Arnd Bergmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox