public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Yongzhi Liu <lyz_cs@pku.edu.cn>,
	jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com,
	rodrigo.vivi@intel.com, airlied@linux.ie, daniel@ffwll.ch,
	thomas.hellstrom@linux.intel.com,
	maarten.lankhorst@linux.intel.com, matthew.auld@intel.com,
	matthew.d.roper@intel.com, tzimmermann@suse.de,
	michal.winiarski@intel.com
Cc: intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	dri-devel@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH] drm/i915: Check input parameter for NULL
Date: Tue, 22 Feb 2022 16:28:24 +0000	[thread overview]
Message-ID: <2b3dd219-7540-6982-15d2-375255921de6@linux.intel.com> (raw)
In-Reply-To: <1645541161-46607-1-git-send-email-lyz_cs@pku.edu.cn>


Hi,

On 22/02/2022 14:46, Yongzhi Liu wrote:
> [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.

I don't think we want this in general, and definitely not just for phys 
objects and leaving others not handle NULL.

See comment at the call site for these vfuncs:

	/*
	 * XXX Temporary hijinx to avoid updating all backends to handle
	 * NULL pages. In the future, when we have more asynchronous
	 * get_pages backends we should be better able to handle the
	 * cancellation of the async task in a more uniform manner.
	 */
	if (!IS_ERR_OR_NULL(pages))
		obj->ops->put_pages(obj, pages);

Maarten owns this area these days so he can comment as well.

Regards,

Tvrtko

> [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);
>   

  reply	other threads:[~2022-02-22 16:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-22 14:46 [Intel-gfx] [PATCH] drm/i915: Check input parameter for NULL Yongzhi Liu
2022-02-22 16:28 ` Tvrtko Ursulin [this message]
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

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=2b3dd219-7540-6982-15d2-375255921de6@linux.intel.com \
    --to=tvrtko.ursulin@linux.intel.com \
    --cc=airlied@linux.ie \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=joonas.lahtinen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lyz_cs@pku.edu.cn \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=matthew.auld@intel.com \
    --cc=matthew.d.roper@intel.com \
    --cc=michal.winiarski@intel.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=thomas.hellstrom@linux.intel.com \
    --cc=tzimmermann@suse.de \
    /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