Re: [PATCH] drm/i915: Allow NULL memory region

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 7/17/2024 5:25 PM, Dan Carpenter wrote:
On Wed, Jul 17, 2024 at 05:05:55PM +0200, Nirmoy Das wrote:
On 7/12/2024 11:41 PM, Jonathan Cavitt wrote:
Prevent a NULL pointer access in intel_memory_regions_hw_probe.

Fixes: 05da7d9f717b ("drm/i915/gem: Downgrade stolen lmem setup warning")
Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
Signed-off-by: Jonathan Cavitt <jonathan.cavitt@xxxxxxxxx>
---
   drivers/gpu/drm/i915/intel_memory_region.c | 6 ++++--
   1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_memory_region.c b/drivers/gpu/drm/i915/intel_memory_region.c
index 172dfa7c3588b..d40ee1b42110a 100644
--- a/drivers/gpu/drm/i915/intel_memory_region.c
+++ b/drivers/gpu/drm/i915/intel_memory_region.c
@@ -368,8 +368,10 @@ int intel_memory_regions_hw_probe(struct drm_i915_private *i915)
   			goto out_cleanup;
   		}
-		mem->id = i;
-		i915->mm.regions[i] = mem;
There is a check for mem just before that. You could use IS_ERR_OR_NULL(mem)
instead of IS_ERR().
An error pointer return is normally completely different from a NULL
return in how it's handled.


intel_memory_regions_driver_release() skipped my eyes  in the cleanup path.

  Here NULL is a special kind of success.  I
wrote a blog about this.

https://staticthinking.wordpress.com/2022/08/01/mixing-error-pointers-and-null/


I am the perfect target audience for this blog post :)


Thanks,

Nirmoy


regards,
dan carpenter



[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux