Skip to content

Commit

Permalink
stmmac: prevent probe drivers to crash kernel
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
andy-shev authored and davem330 committed Jan 27, 2015
1 parent 24e579c commit 9afec6e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2778,6 +2778,9 @@ static int stmmac_hw_init(struct stmmac_priv *priv)
* @addr: iobase memory address
* Description: this is the main probe function used to
* call the alloc_etherdev, allocate the priv structure.
* Return:
* on success the new private structure is returned, otherwise the error
* pointer.
*/
struct stmmac_priv *stmmac_dvr_probe(struct device *device,
struct plat_stmmacenet_data *plat_dat,
Expand All @@ -2789,7 +2792,7 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device,

ndev = alloc_etherdev(sizeof(struct stmmac_priv));
if (!ndev)
return NULL;
return ERR_PTR(-ENOMEM);

SET_NETDEV_DEV(ndev, device);

Expand Down

0 comments on commit 9afec6e

Please sign in to comment.