[PATCH 3/5] staging: netlogic: fix a null dereference if kmalloc fail

Devendra Naga devendra.aaru at gmail.com
Sun Jun 2 17:25:18 UTC 2013


no checks are performed on the return from kmalloc, should check for
valid pointer

Cc: Ganesan Ramalingam <ganesanr at broadcom.com>
Cc: Jayachandran Chandrashekaran Nair <jchandra at broadcom.com>

Signed-off-by: Devendra Naga <devendra.aaru at gmail.com>
---
 drivers/staging/netlogic/xlr_net.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/staging/netlogic/xlr_net.c b/drivers/staging/netlogic/xlr_net.c
index e348915..a228b9d 100644
--- a/drivers/staging/netlogic/xlr_net.c
+++ b/drivers/staging/netlogic/xlr_net.c
@@ -881,6 +881,11 @@ static int xlr_setup_mdio(struct xlr_net_priv *priv,
 	priv->mii_bus->write = xlr_mii_write;
 	priv->mii_bus->parent = &pdev->dev;
 	priv->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
+	if (!priv->mii_bus->irq) {
+		mdiobus_free(priv->mii_bus);
+		return -ENOMEM;
+	}
+
 	priv->mii_bus->irq[priv->phy_addr] = priv->ndev->irq;
 
 	/* Scan only the enabled address */
-- 
1.8.1.4




More information about the devel mailing list