phy: usb: sunplus: Fix potential null-ptr-deref in sp_usb_phy_probe()
Subsystems (3)
PATCH 1/1 phy: usb: sunplus: Fix potential null-ptr-deref in sp_usb_phy_probe()
sp_usb_phy_probe() will call platform_get_resource_byname() that may fail and return NULL. devm_ioremap() will use usbphy->moon4_res_mem->start as input, which may causes null-ptr-deref. Check the ret value of platform_get_resource_byname() to avoid the null-ptr-deref.
Fixes 99d9ccd97385 ("phy: usb: Add USB2.0 phy driver for Sunplus SP7021")
Signed-off-by Shang XiaoJing <[email protected]>
--- drivers/phy/sunplus/phy-sunplus-usb2.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/phy/sunplus/phy-sunplus-usb2.c +3 -0
@@ -254,6 +254,9 @@ static int sp_usb_phy_probe(struct platform_device *pdev)return PTR_ERR (usbphy->phy_regs); usbphy->moon4_res_mem =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"moon4" ); +if (!usbphy->moon4_res_mem) +return -EINVAL ; + usbphy->moon4_regs =devm_ioremap (&pdev->dev, usbphy->moon4_res_mem->start,resource_size (usbphy->moon4_res_mem));if (IS_ERR (usbphy->moon4_regs))
Signature · 1 line
2.17.1
Quoted 4 lines · Shang XiaoJing
sp_usb_phy_probe()will callplatform_get_resource_byname()that may fail and return NULL.devm_ioremap()will useusbphy->moon4_res_mem->startas input, which may causes null-ptr-deref. Check the ret value ofplatform_get_resource_byname()to avoid the null-ptr-deref.
Applied, thanks
Signature · 6 lines
~Vinod -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy