Re: [PATCH] drm/i915: Do not dereference NULL bo->resource

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

 




On 9/19/2022 5:29 PM, Gupta, Anshuman wrote:

-----Original Message-----
From: Das, Nirmoy <nirmoy.das@xxxxxxxxx>
Sent: Monday, September 19, 2022 8:33 PM
To: intel-gfx@xxxxxxxxxxxxxxxxxxxxx
Cc: dri-devel@xxxxxxxxxxxxxxxxxxxxx; Auld, Matthew
<matthew.auld@xxxxxxxxx>; Gupta, Anshuman <anshuman.gupta@xxxxxxxxx>
Subject: [PATCH] drm/i915: Do not dereference NULL bo->resource

bo->resource could be NULL hence add a NULL check for resource before
bo->dereferencing it.
Will bo->resource will be NULL only in case of object is smem or it can be NULL even in lmem case as well ?


It can happen with lmem too. I think we should just use i915_gem_object_is_lmem() instead of i915_ttm_cpu_maps_iomem here.


Nirmoy

Thanks,
Anshuman Gupta.
References: https://gitlab.freedesktop.org/drm/intel/-/issues/6850
Fixes: ad74457a6b5a96 ("drm/i915/dgfx: Release mmap on rpm suspend")
Signed-off-by: Nirmoy Das <nirmoy.das@xxxxxxxxx>
---
  drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
index 0544b0a4a43a..8608801cd9ab 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
@@ -513,7 +513,7 @@ static void i915_ttm_delete_mem_notify(struct
ttm_buffer_object *bo)

  	if (likely(obj)) {
  		/* ttm_bo_release() already has dma_resv_lock */
-		if (i915_ttm_cpu_maps_iomem(bo->resource))
+		if (bo->resource && i915_ttm_cpu_maps_iomem(bo-
resource))
  			wakeref = intel_runtime_pm_get(&to_i915(obj-
base.dev)->runtime_pm);
  		__i915_gem_object_pages_fini(obj);
--
2.37.3



[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux