Skip to contentSkip to conversation

virt: vmgenid: fix return value check in vmgenid_acpi_add()

PATCH In review Wei Yongjun 2 participants 2 messages Feb 26, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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")
---
 drivers/virt/vmgenid.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/virt/vmgenid.c +2 -2
index b503c210c2d7..344f6fcc01da 100644
@@ -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;
 	}
 
#1 lore raw

Hi 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