Skip to content

Commit

Permalink
net: ethernet: ti: cpsw: add missing sanity check
Browse files Browse the repository at this point in the history
Make sure to check for allocation failures before dereferencing a
NULL-pointer during probe.

Fixes: 649a168 ("net: ethernet: ti: cpsw: create common struct to
hold shared driver data")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Johan Hovold authored and David S. Miller committed Nov 18, 2016
1 parent a7fe9d4 commit 3420ea8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/net/ethernet/ti/cpsw.c
Original file line number Diff line number Diff line change
Expand Up @@ -2588,6 +2588,9 @@ static int cpsw_probe(struct platform_device *pdev)
int irq;

cpsw = devm_kzalloc(&pdev->dev, sizeof(struct cpsw_common), GFP_KERNEL);
if (!cpsw)
return -ENOMEM;

cpsw->dev = &pdev->dev;

ndev = alloc_etherdev_mq(sizeof(struct cpsw_priv), CPSW_MAX_QUEUES);
Expand Down

0 comments on commit 3420ea8

Please sign in to comment.