Skip to content

Commit de9e397

Browse files
Radha Mohan Chintakuntladavem330
authored andcommitted
net: mdio-octeon: Fix octeon_mdiobus_probe function for return values
This patch fixes a possible crash in the octeon_mdiobus_probe function if the return values are not handled properly. Signed-off-by: Radha Mohan Chintakuntla <rchintakuntla@cavium.com> Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent a6d6786 commit de9e397

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

drivers/net/phy/mdio-octeon.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,24 +277,28 @@ static int octeon_mdiobus_probe(struct platform_device *pdev)
277277
return -ENOMEM;
278278

279279
res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
280-
281280
if (res_mem == NULL) {
282281
dev_err(&pdev->dev, "found no memory resource\n");
283-
err = -ENXIO;
284-
goto fail;
282+
return -ENXIO;
285283
}
284+
286285
bus->mdio_phys = res_mem->start;
287286
bus->regsize = resource_size(res_mem);
287+
288288
if (!devm_request_mem_region(&pdev->dev, bus->mdio_phys, bus->regsize,
289289
res_mem->name)) {
290290
dev_err(&pdev->dev, "request_mem_region failed\n");
291-
goto fail;
291+
return -ENXIO;
292292
}
293+
293294
bus->register_base =
294295
(u64)devm_ioremap(&pdev->dev, bus->mdio_phys, bus->regsize);
296+
if (!bus->register_base) {
297+
dev_err(&pdev->dev, "dev_ioremap failed\n");
298+
return -ENOMEM;
299+
}
295300

296301
bus->mii_bus = mdiobus_alloc();
297-
298302
if (!bus->mii_bus)
299303
goto fail;
300304

0 commit comments

Comments
 (0)