mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-06 22:55:11 +00:00
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>
This commit is contained in:
parent
b77026b391
commit
1ff219068c
3 changed files with 7 additions and 3 deletions
|
@ -220,6 +220,8 @@ struct mac_device_info *dwmac1000_setup(unsigned long ioaddr)
|
||||||
((uid & 0x0000ff00) >> 8), (uid & 0x000000ff));
|
((uid & 0x0000ff00) >> 8), (uid & 0x000000ff));
|
||||||
|
|
||||||
mac = kzalloc(sizeof(const struct mac_device_info), GFP_KERNEL);
|
mac = kzalloc(sizeof(const struct mac_device_info), GFP_KERNEL);
|
||||||
|
if (!mac)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
mac->mac = &dwmac1000_ops;
|
mac->mac = &dwmac1000_ops;
|
||||||
mac->dma = &dwmac1000_dma_ops;
|
mac->dma = &dwmac1000_dma_ops;
|
||||||
|
|
|
@ -179,6 +179,8 @@ struct mac_device_info *dwmac100_setup(unsigned long ioaddr)
|
||||||
struct mac_device_info *mac;
|
struct mac_device_info *mac;
|
||||||
|
|
||||||
mac = kzalloc(sizeof(const struct mac_device_info), GFP_KERNEL);
|
mac = kzalloc(sizeof(const struct mac_device_info), GFP_KERNEL);
|
||||||
|
if (!mac)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
pr_info("\tDWMAC100\n");
|
pr_info("\tDWMAC100\n");
|
||||||
|
|
||||||
|
|
|
@ -1558,15 +1558,15 @@ static int stmmac_mac_device_setup(struct net_device *dev)
|
||||||
else
|
else
|
||||||
device = dwmac100_setup(ioaddr);
|
device = dwmac100_setup(ioaddr);
|
||||||
|
|
||||||
|
if (!device)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
if (priv->enh_desc) {
|
if (priv->enh_desc) {
|
||||||
device->desc = &enh_desc_ops;
|
device->desc = &enh_desc_ops;
|
||||||
pr_info("\tEnhanced descriptor structure\n");
|
pr_info("\tEnhanced descriptor structure\n");
|
||||||
} else
|
} else
|
||||||
device->desc = &ndesc_ops;
|
device->desc = &ndesc_ops;
|
||||||
|
|
||||||
if (!device)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
priv->hw = device;
|
priv->hw = device;
|
||||||
|
|
||||||
priv->wolenabled = priv->hw->pmt; /* PMT supported */
|
priv->wolenabled = priv->hw->pmt; /* PMT supported */
|
||||||
|
|
Loading…
Add table
Reference in a new issue