diff mbox series

drm/simpledrm: Fix an NULL vs IS_ERR() bug

Message ID Y9JHzImRcUaa0mi1@kili (mailing list archive)
State New, archived
Headers show
Series drm/simpledrm: Fix an NULL vs IS_ERR() bug | expand

Commit Message

Dan Carpenter Jan. 26, 2023, 9:28 a.m. UTC
The devm_memremap() function doesn't return NULL, it returns error
pointers.

Fixes: 9a10c7e6519b ("drm/simpledrm: Add support for system memory framebuffers")
Signed-off-by: Dan Carpenter <error27@gmail.com>
---
 drivers/gpu/drm/tiny/simpledrm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Thomas Zimmermann Jan. 26, 2023, 12:52 p.m. UTC | #1
Am 26.01.23 um 10:28 schrieb Dan Carpenter:
> The devm_memremap() function doesn't return NULL, it returns error
> pointers.
> 
> Fixes: 9a10c7e6519b ("drm/simpledrm: Add support for system memory framebuffers")
> Signed-off-by: Dan Carpenter <error27@gmail.com>

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>

> ---
>   drivers/gpu/drm/tiny/simpledrm.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tiny/simpledrm.c b/drivers/gpu/drm/tiny/simpledrm.c
> index 2acc0eb32489..63881a3754f8 100644
> --- a/drivers/gpu/drm/tiny/simpledrm.c
> +++ b/drivers/gpu/drm/tiny/simpledrm.c
> @@ -719,8 +719,8 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv,
>   		drm_dbg(dev, "using system memory framebuffer at %pr\n", mem);
>   
>   		screen_base = devm_memremap(dev->dev, mem->start, resource_size(mem), MEMREMAP_WC);
> -		if (!screen_base)
> -			return ERR_PTR(-ENOMEM);
> +		if (IS_ERR(screen_base))
> +			return screen_base;
>   
>   		iosys_map_set_vaddr(&sdev->screen_base, screen_base);
>   	} else {
Thierry Reding Jan. 26, 2023, 4:18 p.m. UTC | #2
On Thu, Jan 26, 2023 at 12:28:44PM +0300, Dan Carpenter wrote:
> The devm_memremap() function doesn't return NULL, it returns error
> pointers.
> 
> Fixes: 9a10c7e6519b ("drm/simpledrm: Add support for system memory framebuffers")
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> ---
>  drivers/gpu/drm/tiny/simpledrm.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Good catch! Applied to drm-misc-next, thanks.

Thierry
Thomas Zimmermann Feb. 1, 2023, 10:32 a.m. UTC | #3
Am 26.01.23 um 17:18 schrieb Thierry Reding:
> On Thu, Jan 26, 2023 at 12:28:44PM +0300, Dan Carpenter wrote:
>> The devm_memremap() function doesn't return NULL, it returns error
>> pointers.
>>
>> Fixes: 9a10c7e6519b ("drm/simpledrm: Add support for system memory framebuffers")
>> Signed-off-by: Dan Carpenter <error27@gmail.com>
>> ---
>>   drivers/gpu/drm/tiny/simpledrm.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> Good catch! Applied to drm-misc-next, thanks.

I have cherry-picked the patch into drm-misc-next-fixes.

> 
> Thierry
diff mbox series

Patch

diff --git a/drivers/gpu/drm/tiny/simpledrm.c b/drivers/gpu/drm/tiny/simpledrm.c
index 2acc0eb32489..63881a3754f8 100644
--- a/drivers/gpu/drm/tiny/simpledrm.c
+++ b/drivers/gpu/drm/tiny/simpledrm.c
@@ -719,8 +719,8 @@  static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv,
 		drm_dbg(dev, "using system memory framebuffer at %pr\n", mem);
 
 		screen_base = devm_memremap(dev->dev, mem->start, resource_size(mem), MEMREMAP_WC);
-		if (!screen_base)
-			return ERR_PTR(-ENOMEM);
+		if (IS_ERR(screen_base))
+			return screen_base;
 
 		iosys_map_set_vaddr(&sdev->screen_base, screen_base);
 	} else {