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>
This commit is contained in:
parent
a6d6786452
commit
de9e397e40
|
@ -277,24 +277,28 @@ static int octeon_mdiobus_probe(struct platform_device *pdev)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||||
|
|
||||||
if (res_mem == NULL) {
|
if (res_mem == NULL) {
|
||||||
dev_err(&pdev->dev, "found no memory resource\n");
|
dev_err(&pdev->dev, "found no memory resource\n");
|
||||||
err = -ENXIO;
|
return -ENXIO;
|
||||||
goto fail;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bus->mdio_phys = res_mem->start;
|
bus->mdio_phys = res_mem->start;
|
||||||
bus->regsize = resource_size(res_mem);
|
bus->regsize = resource_size(res_mem);
|
||||||
|
|
||||||
if (!devm_request_mem_region(&pdev->dev, bus->mdio_phys, bus->regsize,
|
if (!devm_request_mem_region(&pdev->dev, bus->mdio_phys, bus->regsize,
|
||||||
res_mem->name)) {
|
res_mem->name)) {
|
||||||
dev_err(&pdev->dev, "request_mem_region failed\n");
|
dev_err(&pdev->dev, "request_mem_region failed\n");
|
||||||
goto fail;
|
return -ENXIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
bus->register_base =
|
bus->register_base =
|
||||||
(u64)devm_ioremap(&pdev->dev, bus->mdio_phys, bus->regsize);
|
(u64)devm_ioremap(&pdev->dev, bus->mdio_phys, bus->regsize);
|
||||||
|
if (!bus->register_base) {
|
||||||
|
dev_err(&pdev->dev, "dev_ioremap failed\n");
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
bus->mii_bus = mdiobus_alloc();
|
bus->mii_bus = mdiobus_alloc();
|
||||||
|
|
||||||
if (!bus->mii_bus)
|
if (!bus->mii_bus)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue