Skip to content

Commit d1ce245

Browse files
Yang Yingliangvinodkoul
authored andcommitted
phy: Sparx5 Eth SerDes: check return value after calling platform_get_resource()
It will cause null-ptr-deref if platform_get_resource() returns NULL, we need check the return value. Signed-off-by: Yang Yingliang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent d6e9e8e commit d1ce245

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/phy/microchip/sparx5_serdes.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2470,6 +2470,10 @@ static int sparx5_serdes_probe(struct platform_device *pdev)
24702470
priv->coreclock = clock;
24712471

24722472
iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
2473+
if (!iores) {
2474+
dev_err(priv->dev, "Invalid resource\n");
2475+
return -EINVAL;
2476+
}
24732477
iomem = devm_ioremap(priv->dev, iores->start, resource_size(iores));
24742478
if (IS_ERR(iomem)) {
24752479
dev_err(priv->dev, "Unable to get serdes registers: %s\n",

0 commit comments

Comments
 (0)