aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/stmmac
diff options
context:
space:
mode:
authorDan Carpenter <error27@gmail.com>2010-07-21 21:16:48 -0400
committerDavid S. Miller <davem@davemloft.net>2010-07-22 17:14:48 -0400
commit1ff219068c0e032a6fd64c45bd69f3bc7374feb6 (patch)
tree9978774f6e4f5b1fbcc2e6dd9e178e31f4c1a9e4 /drivers/net/stmmac
parentb77026b391f4f43ca148cf6c55a93f7487ff6ed8 (diff)
stmmac: handle allocation errors in setup functions
If the allocations fail in either dwmac1000_setup() or dwmac100_setup() then return NULL. These are called from stmmac_mac_device_setup(). The check for NULL returns in stmmac_mac_device_setup() needed to be moved forward a couple lines. Signed-off-by: Dan Carpenter <error27@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/stmmac')
-rw-r--r--drivers/net/stmmac/dwmac1000_core.c2
-rw-r--r--drivers/net/stmmac/dwmac100_core.c2
-rw-r--r--drivers/net/stmmac/stmmac_main.c6
3 files changed, 7 insertions, 3 deletions
diff --git a/drivers/net/stmmac/dwmac1000_core.c b/drivers/net/stmmac/dwmac1000_core.c
index 917b4e16923b..2b2f5c8caf1c 100644
--- a/drivers/net/stmmac/dwmac1000_core.c
+++ b/drivers/net/stmmac/dwmac1000_core.c
@@ -220,6 +220,8 @@ struct mac_device_info *dwmac1000_setup(unsigned long ioaddr)
220 ((uid & 0x0000ff00) >> 8), (uid & 0x000000ff)); 220 ((uid & 0x0000ff00) >> 8), (uid & 0x000000ff));
221 221
222 mac = kzalloc(sizeof(const struct mac_device_info), GFP_KERNEL); 222 mac = kzalloc(sizeof(const struct mac_device_info), GFP_KERNEL);
223 if (!mac)
224 return NULL;
223 225
224 mac->mac = &dwmac1000_ops; 226 mac->mac = &dwmac1000_ops;
225 mac->dma = &dwmac1000_dma_ops; 227 mac->dma = &dwmac1000_dma_ops;
diff --git a/drivers/net/stmmac/dwmac100_core.c b/drivers/net/stmmac/dwmac100_core.c
index 6f270a0e151a..2fb165fa2ba0 100644
--- a/drivers/net/stmmac/dwmac100_core.c
+++ b/drivers/net/stmmac/dwmac100_core.c
@@ -179,6 +179,8 @@ struct mac_device_info *dwmac100_setup(unsigned long ioaddr)
179 struct mac_device_info *mac; 179 struct mac_device_info *mac;
180 180
181 mac = kzalloc(sizeof(const struct mac_device_info), GFP_KERNEL); 181 mac = kzalloc(sizeof(const struct mac_device_info), GFP_KERNEL);
182 if (!mac)
183 return NULL;
182 184
183 pr_info("\tDWMAC100\n"); 185 pr_info("\tDWMAC100\n");
184 186
diff --git a/drivers/net/stmmac/stmmac_main.c b/drivers/net/stmmac/stmmac_main.c
index acf061686940..0bdd3326c94a 100644
--- a/drivers/net/stmmac/stmmac_main.c
+++ b/drivers/net/stmmac/stmmac_main.c
@@ -1558,15 +1558,15 @@ static int stmmac_mac_device_setup(struct net_device *dev)
1558 else 1558 else
1559 device = dwmac100_setup(ioaddr); 1559 device = dwmac100_setup(ioaddr);
1560 1560
1561 if (!device)
1562 return -ENOMEM;
1563
1561 if (priv->enh_desc) { 1564 if (priv->enh_desc) {
1562 device->desc = &enh_desc_ops; 1565 device->desc = &enh_desc_ops;
1563 pr_info("\tEnhanced descriptor structure\n"); 1566 pr_info("\tEnhanced descriptor structure\n");
1564 } else 1567 } else
1565 device->desc = &ndesc_ops; 1568 device->desc = &ndesc_ops;
1566 1569
1567 if (!device)
1568 return -ENOMEM;
1569
1570 priv->hw = device; 1570 priv->hw = device;
1571 1571
1572 priv->wolenabled = priv->hw->pmt; /* PMT supported */ 1572 priv->wolenabled = priv->hw->pmt; /* PMT supported */