Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: mvpp2: check return value after calling platform_get_resource()

It will cause null-ptr-deref if platform_get_resource() returns NULL,
we need check the return value.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Yang Yingliang and committed by
David S. Miller
0bb51a3a 3710e809

+4
+4
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
··· 7377 7377 return PTR_ERR(priv->lms_base); 7378 7378 } else { 7379 7379 res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 7380 + if (!res) { 7381 + dev_err(&pdev->dev, "Invalid resource\n"); 7382 + return -EINVAL; 7383 + } 7380 7384 if (has_acpi_companion(&pdev->dev)) { 7381 7385 /* In case the MDIO memory region is declared in 7382 7386 * the ACPI, it can already appear as 'in-use'