net: ethernet: ti: cpsw: add missing sanity check

Make sure to check for allocation failures before dereferencing a
NULL-pointer during probe.

Fixes: 649a1688c9 ("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>
This commit is contained in:
Johan Hovold 2016-11-17 17:40:03 +01:00 committed by David S. Miller
parent a7fe9d466f
commit 3420ea8850
1 changed files with 3 additions and 0 deletions

View File

@ -2588,6 +2588,9 @@ static int cpsw_probe(struct platform_device *pdev)
int irq; int irq;
cpsw = devm_kzalloc(&pdev->dev, sizeof(struct cpsw_common), GFP_KERNEL); cpsw = devm_kzalloc(&pdev->dev, sizeof(struct cpsw_common), GFP_KERNEL);
if (!cpsw)
return -ENOMEM;
cpsw->dev = &pdev->dev; cpsw->dev = &pdev->dev;
ndev = alloc_etherdev_mq(sizeof(struct cpsw_priv), CPSW_MAX_QUEUES); ndev = alloc_etherdev_mq(sizeof(struct cpsw_priv), CPSW_MAX_QUEUES);