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

net: marvell: fix a missing check of acpi_match_device

When acpi_match_device fails, its return value is NULL. Directly using
the return value without a check may result in a NULL-pointer
dereference. The fix checks if acpi_match_device fails, and if so,
returns -EINVAL.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Kangjie Lu and committed by
David S. Miller
92ee77d1 46273cf7

+2
+2
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
··· 5255 5255 if (has_acpi_companion(&pdev->dev)) { 5256 5256 acpi_id = acpi_match_device(pdev->dev.driver->acpi_match_table, 5257 5257 &pdev->dev); 5258 + if (!acpi_id) 5259 + return -EINVAL; 5258 5260 priv->hw_version = (unsigned long)acpi_id->driver_data; 5259 5261 } else { 5260 5262 priv->hw_version =