Skip to content

Commit 17eee26

Browse files
Shang XiaoJingvinodkoul
authored andcommitted
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: 99d9ccd ("phy: usb: Add USB2.0 phy driver for Sunplus SP7021") Signed-off-by: Shang XiaoJing <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 7124c93 commit 17eee26

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/phy/sunplus/phy-sunplus-usb2.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,9 @@ static int sp_usb_phy_probe(struct platform_device *pdev)
254254
return PTR_ERR(usbphy->phy_regs);
255255

256256
usbphy->moon4_res_mem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "moon4");
257+
if (!usbphy->moon4_res_mem)
258+
return -EINVAL;
259+
257260
usbphy->moon4_regs = devm_ioremap(&pdev->dev, usbphy->moon4_res_mem->start,
258261
resource_size(usbphy->moon4_res_mem));
259262
if (!usbphy->moon4_regs)

0 commit comments

Comments
 (0)