All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/i915: Check input parameter for NULL
@ 2022-02-21 14:53 ` Yongzhi Liu
  0 siblings, 0 replies; 13+ messages in thread
From: Yongzhi Liu @ 2022-02-21 14:53 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 | 2 ++
 1 file changed, 2 insertions(+)

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


^ permalink raw reply related	[flat|nested] 13+ messages in thread
* [Intel-gfx] [PATCH] drm/i915: Check input parameter for NULL
@ 2022-02-22 14:46 Yongzhi Liu
  2022-02-22 16:28 ` Tvrtko Ursulin
  0 siblings, 1 reply; 13+ 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] 13+ messages in thread

end of thread, other threads:[~2022-02-23 13:53 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-21 14:53 [PATCH] drm/i915: Check input parameter for NULL Yongzhi Liu
2022-02-21 14:53 ` Yongzhi Liu
2022-02-21 23:41 ` [Intel-gfx] " kernel test robot
2022-02-21 23:41   ` kernel test robot
2022-02-21 23:41   ` kernel test robot
2022-02-22  0:12 ` [Intel-gfx] " kernel test robot
2022-02-22  0:12   ` kernel test robot
2022-02-22  0:12   ` kernel test robot
2022-02-22  1:23 ` [Intel-gfx] " kernel test robot
2022-02-22  1:23   ` kernel test robot
2022-02-22  1:23   ` kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2022-02-22 14:46 [Intel-gfx] " Yongzhi Liu
2022-02-22 16:28 ` Tvrtko Ursulin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.