public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Pallavi Mishra <pallavi.mishra@intel.com>
Cc: thomas.hellstrom@linux.intel.com, intel-gfx@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH] drm/i915: Fix possible null ptr dereferences
Date: Fri, 3 Dec 2021 13:02:28 +0200	[thread overview]
Message-ID: <Yan5RE4+T7hTHDI/@intel.com> (raw)
In-Reply-To: <20211203063257.52053-1-pallavi.mishra@intel.com>

On Fri, Dec 03, 2021 at 12:02:57PM +0530, Pallavi Mishra wrote:
> add null ptr checks to prevent crash/exceptions.

BUG_ON()s aren't going to fix anything.

> Signed-off-by: Pallavi Mishra <pallavi.mishra@intel.com>
> ---
>  drivers/gpu/drm/i915/gem/i915_gem_ttm.c      | 3 +++
>  drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c | 3 ++-
>  2 files changed, 5 insertions(+), 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 218a9b3037c7..997fe73c205b 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
> @@ -906,6 +906,8 @@ vm_access_ttm(struct vm_area_struct *area, unsigned long addr,
>  	struct drm_i915_gem_object *obj =
>  		i915_ttm_to_gem(area->vm_private_data);
>  
> +	GEM_BUG_ON(!obj);
> +
>  	if (i915_gem_object_is_readonly(obj) && write)
>  		return -EACCES;
>  
> @@ -966,6 +968,7 @@ static const struct drm_i915_gem_object_ops i915_gem_ttm_obj_ops = {
>  void i915_ttm_bo_destroy(struct ttm_buffer_object *bo)
>  {
>  	struct drm_i915_gem_object *obj = i915_ttm_to_gem(bo);
> +	GEM_BUG_ON(!obj);
>  
>  	i915_gem_object_release_memory_region(obj);
>  	mutex_destroy(&obj->ttm.get_io_page.lock);
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c b/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c
> index 80df9f592407..2b684903a9f5 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c
> @@ -371,6 +371,7 @@ int i915_ttm_move_notify(struct ttm_buffer_object *bo)
>  	struct drm_i915_gem_object *obj = i915_ttm_to_gem(bo);
>  	int ret;
>  
> +	GEM_BUG_ON(!obj);
>  	ret = i915_gem_object_unbind(obj, I915_GEM_OBJECT_UNBIND_ACTIVE);
>  	if (ret)
>  		return ret;
> @@ -506,7 +507,7 @@ static void i915_ttm_memcpy_init(struct i915_ttm_memcpy_arg *arg,
>  
>  	dst_reg = i915_ttm_region(bo->bdev, dst_mem->mem_type);
>  	src_reg = i915_ttm_region(bo->bdev, bo->resource->mem_type);
> -	GEM_BUG_ON(!dst_reg || !src_reg);
> +	GEM_BUG_ON(!dst_reg || !src_reg || !obj);
>  
>  	arg->dst_iter = !i915_ttm_cpu_maps_iomem(dst_mem) ?
>  		ttm_kmap_iter_tt_init(&arg->_dst_iter.tt, dst_ttm) :
> -- 
> 2.25.1

-- 
Ville Syrjälä
Intel

  parent reply	other threads:[~2021-12-03 11:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-03  6:32 [Intel-gfx] [PATCH] drm/i915: Fix possible null ptr dereferences Pallavi Mishra
2021-12-03  8:20 ` [Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915: Fix possible null ptr dereferences (rev2) Patchwork
2021-12-03 10:58 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
2021-12-03 11:02 ` Ville Syrjälä [this message]
2021-12-03 11:07   ` [Intel-gfx] [PATCH] drm/i915: Fix possible null ptr dereferences Thomas Hellström
2021-12-09 13:25     ` Jani Nikula
  -- strict thread matches above, loose matches on Subject: below --
2021-12-02 11:28 Pallavi Mishra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yan5RE4+T7hTHDI/@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=pallavi.mishra@intel.com \
    --cc=thomas.hellstrom@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox