Skip to contentSkip to conversation

usb: typec: ucsi: acpi: fix a NULL vs IS_ERR() check in probe

PATCH In review Dan Carpenter 4 participants 4 messages May 9, 2022 – May 30, 2022

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

PATCH 1/1 usb: typec: ucsi: acpi: fix a NULL vs IS_ERR() check in probe

The devm_memremap() function never returns NULL. It returns error pointers.

Fixes cdc3d2abf438 ("usb: typec: ucsi: acpi: Map the mailbox with memremap()")
---
 drivers/usb/typec/ucsi/ucsi_acpi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/typec/ucsi/ucsi_acpi.c +2 -2
index 7455e3aff2be..8873c1644a29 100644
@@ -133,8 +133,8 @@ static int ucsi_acpi_probe(struct platform_device *pdev)
 	}
 
 	ua->base = devm_memremap(&pdev->dev, res->start, resource_size(res), MEMREMAP_WB);
-	if (!ua->base)
-		return -ENOMEM;
+	if (IS_ERR(ua->base))
+		return PTR_ERR(ua->base);
 
 	ret = guid_parse(UCSI_DSM_UUID, &ua->guid);
 	if (ret)
Signature · 1 line
2.35.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 2 lines · Dan Carpenter

The devm_memremap() function never returns NULL. It returns error pointers.

Oh, so memremap() and devm_memremap() don't behave the same way. That's a bummer. Thanks for catching this.

Quoted 23 lines
Fixes cdc3d2abf438 ("usb: typec: ucsi: acpi: Map the mailbox with memremap()")
---
 drivers/usb/typec/ucsi/ucsi_acpi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/typec/ucsi/ucsi_acpi.c +2 -2
index 7455e3aff2be..8873c1644a29 100644
@@ -133,8 +133,8 @@ static int ucsi_acpi_probe(struct platform_device *pdev)
 	}
 
 	ua->base = devm_memremap(&pdev->dev, res->start, resource_size(res), MEMREMAP_WB);
-	if (!ua->base)
-		return -ENOMEM;
+	if (IS_ERR(ua->base))
+		return PTR_ERR(ua->base);
 
 	ret = guid_parse(UCSI_DSM_UUID, &ua->guid);
 	if (ret)
Signature · 1 line
2.35.1
Signature · 1 line
heikki
#3 lore raw
Quoted 8 lines · Greg Kroah-Hartman
Quoted 4 lines · Dan Carpenter

The devm_memremap() function never returns NULL. It returns error pointers.

Fixes cdc3d2abf438 ("usb: typec: ucsi: acpi: Map the mailbox with memremap()")

As this is in Rafael's tree, he needs to take it, I can't:

Applied now, thanks!

Fortunately, I've not pushed the original change before applying it.