Skip to contentSkip to conversation

usb: typec: ucsi: fix return value check in ucsi_acpi_probe()

PATCH In review Yang Yingliang 3 participants 3 messages May 16, 2022 – May 17, 2022

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

PATCH 1/1 usb: typec: ucsi: fix return value check in ucsi_acpi_probe()

If memremap() fails, it never returns NULL. Replace NULL check with IS_ERR().

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.25.1
#1 lore raw

Hello!

Quoted 1 line · Yang Yingliang

If memremap() fails, it never returns NULL. Replace NULL check

Oh, memremap() does! But devm_memremap() doesn't, indeed. :-)

Quoted 14 lines

with IS_ERR().

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 +0 -0
index 7455e3aff2be..8873c1644a29 100644

drivers/usb/typec/ucsi/ucsi_acpi.c static int ucsi_acpi_probe(struct platform_device *pdev) · line 140

Quoted 10 lines
drivers/usb/typec/ucsi/ucsi_acpi.c +2 -2
@@ -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)

MBR, Sergey

maintainer
#2 lore raw
In reply to Yang Yingliang
Quoted 2 lines · Yang Yingliang

If memremap() fails, it never returns NULL. Replace NULL check with IS_ERR().

There's already a fix pending for this:
https://patchwork.kernel.org/project/linux-usb/patch/YnjaDBXLmwouCB3M@kili/

thanks,

Quoted 22 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
heikki