aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/stmicro/stmmac
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2015-01-27 11:38:03 -0500
committerDavid S. Miller <davem@davemloft.net>2015-01-27 15:24:30 -0500
commit9afec6efc6b1043692eada758cd7837623dd943b (patch)
treeb377e0790a0889110cf17a20470cc433b626336b /drivers/net/ethernet/stmicro/stmmac
parent24e579c8898aa641ede3149234906982290934e5 (diff)
stmmac: prevent probe drivers to crash kernel
In the case when alloc_netdev fails we return NULL to a caller. But there is no check for NULL in the probe drivers. This patch changes NULL to an error pointer. The function description is amended to reflect what we may get returned. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/stmicro/stmmac')
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 8c6b7c1651e5..cf62ff4c8c56 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -2778,6 +2778,9 @@ static int stmmac_hw_init(struct stmmac_priv *priv)
2778 * @addr: iobase memory address 2778 * @addr: iobase memory address
2779 * Description: this is the main probe function used to 2779 * Description: this is the main probe function used to
2780 * call the alloc_etherdev, allocate the priv structure. 2780 * call the alloc_etherdev, allocate the priv structure.
2781 * Return:
2782 * on success the new private structure is returned, otherwise the error
2783 * pointer.
2781 */ 2784 */
2782struct stmmac_priv *stmmac_dvr_probe(struct device *device, 2785struct stmmac_priv *stmmac_dvr_probe(struct device *device,
2783 struct plat_stmmacenet_data *plat_dat, 2786 struct plat_stmmacenet_data *plat_dat,
@@ -2789,7 +2792,7 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device,
2789 2792
2790 ndev = alloc_etherdev(sizeof(struct stmmac_priv)); 2793 ndev = alloc_etherdev(sizeof(struct stmmac_priv));
2791 if (!ndev) 2794 if (!ndev)
2792 return NULL; 2795 return ERR_PTR(-ENOMEM);
2793 2796
2794 SET_NETDEV_DEV(ndev, device); 2797 SET_NETDEV_DEV(ndev, device);
2795 2798