Skip to contentSkip to conversation

net: r6040: Return proper error for r6040_init_one

PATCH Applied Axel Lin 3 participants 3 messages Jan 5, 2011 – Jan 6, 2011

Subsystems (2)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 net: r6040: Return proper error for r6040_init_one

Return -ENOMEM instead of 0 for the case of mdiobus_alloc and kmalloc failure.

---
 drivers/net/r6040.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/net/r6040.c +2 -0
index 0b014c89..27e6f6d 100644
@@ -1153,6 +1153,7 @@ static int __devinit r6040_init_one(struct pci_dev *pdev,
 	lp->mii_bus = mdiobus_alloc();
 	if (!lp->mii_bus) {
 		dev_err(&pdev->dev, "mdiobus_alloc() failed\n");
+		err = -ENOMEM;
 		goto err_out_unmap;
 	}
 
@@ -1165,6 +1166,7 @@ static int __devinit r6040_init_one(struct pci_dev *pdev,
 	lp->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
 	if (!lp->mii_bus->irq) {
 		dev_err(&pdev->dev, "mii_bus irq allocation failed\n");
+		err = -ENOMEM;
 		goto err_out_mdio;
 	}
 
Signature · 1 line
1.7.2
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · On Wednesday 05 January 2011 09:40:04 Axel Lin wrote:

Return -ENOMEM instead of 0 for the case of mdiobus_alloc and kmalloc failure.

Quoted 23 lines
---
 drivers/net/r6040.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/net/r6040.c +2 -0
index 0b014c89..27e6f6d 100644
@@ -1153,6 +1153,7 @@ static int __devinit r6040_init_one(struct pci_dev
 *pdev, lp->mii_bus = mdiobus_alloc();
 	if (!lp->mii_bus) {
 		dev_err(&pdev->dev, "mdiobus_alloc() failed\n");
+		err = -ENOMEM;
 		goto err_out_unmap;
 	}
 
@@ -1165,6 +1166,7 @@ static int __devinit r6040_init_one(struct pci_dev
 *pdev, lp->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
 if (!lp->mii_bus->irq) {
 		dev_err(&pdev->dev, "mii_bus irq allocation failed\n");
+		err = -ENOMEM;
 		goto err_out_mdio;
 	}