public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
* [Intel-gfx] [PATCH] drm/i915: Check input parameter for NULL
@ 2022-02-22 14:46 Yongzhi Liu
  2022-02-22 16:28 ` Tvrtko Ursulin
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Yongzhi Liu @ 2022-02-22 14:46 UTC (permalink / raw)
  To: jani.nikula, joonas.lahtinen, rodrigo.vivi, tvrtko.ursulin,
	airlied, daniel, thomas.hellstrom, maarten.lankhorst,
	matthew.auld, matthew.d.roper, lyz_cs, tzimmermann,
	michal.winiarski
  Cc: intel-gfx, linux-kernel, dri-devel

[why]
i915_gem_object_put_pages_phys() frees pages and standard
pattern is to allow caller to not care if it's
NULL or not. This will reduce burden on
the callers to perform this check.

[how]
Fix it by adding Null check.

Signed-off-by: Yongzhi Liu <lyz_cs@pku.edu.cn>
---
 drivers/gpu/drm/i915/gem/i915_gem_phys.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_phys.c b/drivers/gpu/drm/i915/gem/i915_gem_phys.c
index ca6faff..09c3dcb 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_phys.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_phys.c
@@ -95,8 +95,13 @@ void
 i915_gem_object_put_pages_phys(struct drm_i915_gem_object *obj,
 			       struct sg_table *pages)
 {
-	dma_addr_t dma = sg_dma_address(pages->sgl);
-	void *vaddr = sg_page(pages->sgl);
+	dma_addr_t dma;
+	void *vaddr;
+
+	if (!pages)
+		return;
+	dma = sg_dma_address(pages->sgl);
+	vaddr = sg_page(pages->sgl);
 
 	__i915_gem_object_release_shmem(obj, pages, false);
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread
[parent not found: <1645455221-38580-1-git-send-email-lyz_cs@pku.edu.cn>]

end of thread, other threads:[~2022-02-24 11:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-22 14:46 [Intel-gfx] [PATCH] drm/i915: Check input parameter for NULL Yongzhi Liu
2022-02-22 16:28 ` Tvrtko Ursulin
2022-02-24 11:00 ` [Intel-gfx] ✗ Fi.CI.SPARSE: warning for " Patchwork
2022-02-24 11:32 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork
     [not found] <1645455221-38580-1-git-send-email-lyz_cs@pku.edu.cn>
2022-02-21 23:41 ` [Intel-gfx] [PATCH] " kernel test robot
2022-02-22  0:12 ` kernel test robot
2022-02-22  1:23 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox