virt: vmgenid: fix return value check in vmgenid_acpi_add()
Subsystems (2)
PATCH 1/1 virt: vmgenid: fix return value check in vmgenid_acpi_add()
In case of error, the function devm_memremap() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR().
Fixes d54207b61470 ("virt: vmgenid: introduce driver for reinitializing RNG on VM fork")
Reported-by Hulk Robot <[email protected]>
Signed-off-by Wei Yongjun <[email protected]>
--- drivers/virt/vmgenid.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/virt/vmgenid.c +2 -2
@@ -50,8 +50,8 @@ static int vmgenid_acpi_add(struct acpi_device *device) phys_addr = (obj->package.elements[0 ].integer.value <<0 ) | (obj->package.elements[1 ].integer.value <<32 ); state->next_id =devm_memremap (&device->dev, phys_addr,VMGENID_SIZE ,MEMREMAP_WB ); -if (!state->next_id) { - ret = -ENOMEM ; +if (IS_ERR (state->next_id)) { + ret =PTR_ERR (state->next_id); goto out; }
Jason A. Donenfeld
maintainerHi Wei,
Thanks! I'll probably fold this into a v+1 of that patch, as we're also waiting on some ACPI changes elsewhere. I'll CC you when I do that.
Regards,
Jason