Skip to content

Commit f00af5c

Browse files
Yang Yingliangdavem330
authored andcommitted
net: sparx5: 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. Fixes: 3cfa11b ("net: sparx5: add the basic sparx5 driver") Signed-off-by: Yang Yingliang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4bec3ce commit f00af5c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/net/ethernet/microchip/sparx5/sparx5_main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,10 @@ static int sparx5_create_targets(struct sparx5 *sparx5)
228228
for (idx = 0; idx < IO_RANGES; idx++) {
229229
iores[idx] = platform_get_resource(sparx5->pdev, IORESOURCE_MEM,
230230
idx);
231+
if (!iores[idx]) {
232+
dev_err(sparx5->dev, "Invalid resource\n");
233+
return -EINVAL;
234+
}
231235
iomem[idx] = devm_ioremap(sparx5->dev,
232236
iores[idx]->start,
233237
iores[idx]->end - iores[idx]->start

0 commit comments

Comments
 (0)