diff mbox series

drm/i915: Fix a NULL vs IS_ERR() bug

Message ID ZH7tHLRZ9oBjedjN@moroto (mailing list archive)
State New, archived
Headers show
Series drm/i915: Fix a NULL vs IS_ERR() bug | expand

Commit Message

Dan Carpenter June 6, 2023, 8:23 a.m. UTC
The mmap_offset_attach() function returns error pointers, it doesn't
return NULL.

Fixes: eaee1c085863 ("drm/i915: Add a function to mmap framebuffer obj")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/gpu/drm/i915/gem/i915_gem_mman.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Nirmoy Das June 6, 2023, 8:51 a.m. UTC | #1
On 6/6/2023 10:23 AM, Dan Carpenter wrote:
> The mmap_offset_attach() function returns error pointers, it doesn't
> return NULL.
>
> Fixes: eaee1c085863 ("drm/i915: Add a function to mmap framebuffer obj")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

Reviewed-by: Nirmoy Das <nirmoy.das@intel.com>


Thanks,

Nirmoy

> ---
>   drivers/gpu/drm/i915/gem/i915_gem_mman.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
> index 4e7a838ab7bd..aa4d842d4c5a 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
> @@ -1085,8 +1085,8 @@ int i915_gem_fb_mmap(struct drm_i915_gem_object *obj, struct vm_area_struct *vma
>   		/* handle stolen and smem objects */
>   		mmap_type = i915_ggtt_has_aperture(ggtt) ? I915_MMAP_TYPE_GTT : I915_MMAP_TYPE_WC;
>   		mmo = mmap_offset_attach(obj, mmap_type, NULL);
> -		if (!mmo)
> -			return -ENODEV;
> +		if (IS_ERR(mmo))
> +			return PTR_ERR(mmo);
>   	}
>   
>   	/*
Andi Shyti June 6, 2023, 9:22 a.m. UTC | #2
Hi Dan,

On Tue, Jun 06, 2023 at 11:23:56AM +0300, Dan Carpenter wrote:
> The mmap_offset_attach() function returns error pointers, it doesn't
> return NULL.
> 
> Fixes: eaee1c085863 ("drm/i915: Add a function to mmap framebuffer obj")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

Thanks for this series of fixes!

Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com> 

Andi
Nirmoy Das June 19, 2023, 2:06 p.m. UTC | #3
Pushed to gt-next.


Thanks,

Nirmoy

On 6/6/2023 11:22 AM, Andi Shyti wrote:
> Hi Dan,
>
> On Tue, Jun 06, 2023 at 11:23:56AM +0300, Dan Carpenter wrote:
>> The mmap_offset_attach() function returns error pointers, it doesn't
>> return NULL.
>>
>> Fixes: eaee1c085863 ("drm/i915: Add a function to mmap framebuffer obj")
>> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> Thanks for this series of fixes!
>
> Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com>
>
> Andi
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
index 4e7a838ab7bd..aa4d842d4c5a 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
@@ -1085,8 +1085,8 @@  int i915_gem_fb_mmap(struct drm_i915_gem_object *obj, struct vm_area_struct *vma
 		/* handle stolen and smem objects */
 		mmap_type = i915_ggtt_has_aperture(ggtt) ? I915_MMAP_TYPE_GTT : I915_MMAP_TYPE_WC;
 		mmo = mmap_offset_attach(obj, mmap_type, NULL);
-		if (!mmo)
-			return -ENODEV;
+		if (IS_ERR(mmo))
+			return PTR_ERR(mmo);
 	}
 
 	/*