From: Johan Hovold Date: Thu, 17 Nov 2016 16:40:03 +0000 (+0100) Subject: net: ethernet: ti: cpsw: add missing sanity check X-Git-Tag: v4.9-rc7~33^2~12^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3420ea88509f9d585b39f36e737022faf0286d9a;p=platform%2Fkernel%2Flinux-exynos.git net: ethernet: ti: cpsw: add missing sanity check Make sure to check for allocation failures before dereferencing a NULL-pointer during probe. Fixes: 649a1688c960 ("net: ethernet: ti: cpsw: create common struct to hold shared driver data") Signed-off-by: Johan Hovold Signed-off-by: David S. Miller --- diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index 11b2dae..1387299 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c @@ -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);