diff mbox series

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

Message ID YnjaDBXLmwouCB3M@kili (mailing list archive)
State Accepted
Commit a9face899413f468460219c79503c091c4d362cb
Headers show
Series usb: typec: ucsi: acpi: fix a NULL vs IS_ERR() check in probe | expand

Commit Message

Dan Carpenter May 9, 2022, 9:08 a.m. UTC
The devm_memremap() function never returns NULL.  It returns error
pointers.

Fixes: cdc3d2abf438 ("usb: typec: ucsi: acpi: Map the mailbox with memremap()")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/usb/typec/ucsi/ucsi_acpi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Heikki Krogerus May 9, 2022, 1:14 p.m. UTC | #1
On Mon, May 09, 2022 at 12:08:28PM +0300, Dan Carpenter wrote:
> 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.

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> Fixes: cdc3d2abf438 ("usb: typec: ucsi: acpi: Map the mailbox with memremap()")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  drivers/usb/typec/ucsi/ucsi_acpi.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/typec/ucsi/ucsi_acpi.c b/drivers/usb/typec/ucsi/ucsi_acpi.c
> index 7455e3aff2be..8873c1644a29 100644
> --- a/drivers/usb/typec/ucsi/ucsi_acpi.c
> +++ b/drivers/usb/typec/ucsi/ucsi_acpi.c
> @@ -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)
> -- 
> 2.35.1
Greg Kroah-Hartman May 12, 2022, 9:36 a.m. UTC | #2
On Mon, May 09, 2022 at 12:08:28PM +0300, Dan Carpenter wrote:
> 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:

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Wysocki, Rafael J May 30, 2022, 4:10 p.m. UTC | #3
On 5/12/2022 11:36 AM, Greg Kroah-Hartman wrote:
> On Mon, May 09, 2022 at 12:08:28PM +0300, Dan Carpenter wrote:
>> 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:
>
> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Applied now, thanks!

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

Patch

diff --git a/drivers/usb/typec/ucsi/ucsi_acpi.c b/drivers/usb/typec/ucsi/ucsi_acpi.c
index 7455e3aff2be..8873c1644a29 100644
--- a/drivers/usb/typec/ucsi/ucsi_acpi.c
+++ b/drivers/usb/typec/ucsi/ucsi_acpi.c
@@ -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)