Subject: [PATCH 1/3] chelsio: fix error path

From: Stephen Hemminger <[email-masked]>
Date: Fri, 15 Dec 2006 11:07:17 -0800

Fix handling of allocation failure.

Signed-off-by: Stephen Hemminger <[email-masked]>

--- linux-2.6.20-rc1.orig/drivers/net/chelsio/my3126.c
+++ linux-2.6.20-rc1/drivers/net/chelsio/my3126.c
@@ -170,13 +170,14 @@ static struct cphy *my3126_phy_create(ad
 {
 	struct cphy *cphy = kzalloc(sizeof (*cphy), GFP_KERNEL);
 
-	if (cphy)
-		cphy_init(cphy, adapter, phy_addr, &my3126_ops, mdio_ops);
+	if (!cphy)
+		return NULL;
 
+	cphy_init(cphy, adapter, phy_addr, &my3126_ops, mdio_ops);
 	INIT_DELAYED_WORK(&cphy->phy_update, my3216_poll);
 	cphy->bmsr = 0;
 
-	return (cphy);
+	return cphy;
 }
 
 /* Chip Reset */

--