virt: vmgenid: Add Null check for device
PATCH 1/1 virt: vmgenid: Add Null check for device
Not all devices have an ACPI companion fwnode, so device might be NULL. This is similar to the commit cd2fd6eab480
("platform/x86: int3472: Check for adev == NULL").
Add a check for device not being set and return -ENODEV in that case to avoid a possible NULL pointer deref in vmgenid_add_acpi().
Signed-off-by Chenyuan Yang <[email protected]>
--- drivers/virt/vmgenid.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/virt/vmgenid.c +3 -0
@@ -59,6 +59,9 @@ static int vmgenid_add_acpi(struct device *dev, struct vmgenid_state *state)void *virt_addr;int ret =0 ; +if (!device) +return -ENODEV ; + status =acpi_evaluate_object (device->handle,"ADDR" ,NULL , &parsed);if (ACPI_FAILURE (status)) {ACPI_EXCEPTION ((AE_INFO , status,"Evaluating ADDR" ));
Signature · 1 line
2.34.1
Jason A. Donenfeld
maintainerQuoted 6 lines · Chenyuan Yang
Not all devices have an ACPI companion fwnode, so device might be NULL. This is similar to the commit
cd2fd6eab480
("platform/x86: int3472: Check for adev == NULL").Add a check for device not being set and return
-ENODEVin that case to avoid a possible NULL pointer deref invmgenid_add_acpi().
Is this causing a crash on some systems? What's happening here? "Not all devices" - which ones, and why?
Jason