All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Cc: <intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH 2/3] drm/xe/vf: Remove lmtt->ops null check in xe_lmtt_estimate_pt_size
Date: Fri, 8 Mar 2024 09:52:18 -0500	[thread overview]
Message-ID: <ZesmInDmDsLY1uPh@intel.com> (raw)
In-Reply-To: <20240308043651.2010165-3-himal.prasad.ghimiray@intel.com>

On Fri, Mar 08, 2024 at 10:06:50AM +0530, Himal Prasad Ghimiray wrote:
> In xe_lmtt_estimate_pt_size: Pointer is checked against null but then
> dereferenced anyway. 

And what's the problem?

In the line below it access beyond this pointer, so it is a fair
case.

> Since xe_lmtt_init ensures lmtt->ops is populated
> remove the check.

With this in mind we could simply remove all the asserts in the code.

I believe that if someone introduced it here it is likely because
during some development or refactor this ended up being a problem
and want some earlier kind of warning with backtrace information.

> 
> Reported by static analyzer.

Perhaps then replace with an
if (!lmtt->ops) {
    drm_WARN(...);
    return;
}

and/or mark the tool as a false positive?!

> 
> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
> ---
>  drivers/gpu/drm/xe/xe_lmtt.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_lmtt.c b/drivers/gpu/drm/xe/xe_lmtt.c
> index 0d7c5514e092..d6d75414bb99 100644
> --- a/drivers/gpu/drm/xe/xe_lmtt.c
> +++ b/drivers/gpu/drm/xe/xe_lmtt.c
> @@ -487,7 +487,6 @@ u64 xe_lmtt_estimate_pt_size(struct xe_lmtt *lmtt, u64 size)
>  
>  	lmtt_assert(lmtt, IS_SRIOV_PF(lmtt_to_xe(lmtt)));
>  	lmtt_assert(lmtt, IS_DGFX(lmtt_to_xe(lmtt)));
> -	lmtt_assert(lmtt, lmtt->ops);
>  
>  	pt_size = PAGE_ALIGN(lmtt->ops->lmtt_pte_size(level) *
>  			     lmtt->ops->lmtt_pte_num(level));
> -- 
> 2.25.1
> 

  reply	other threads:[~2024-03-08 14:52 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-08  4:36 [PATCH 0/3] Minor fixes for errors reported by static analyzer Himal Prasad Ghimiray
2024-03-08  4:33 ` ✓ CI.Patch_applied: success for " Patchwork
2024-03-08  4:33 ` ✓ CI.checkpatch: " Patchwork
2024-03-08  4:35 ` ✓ CI.KUnit: " Patchwork
2024-03-08  4:36 ` [PATCH 1/3] drm/xe: Return if kobj creation is failed Himal Prasad Ghimiray
2024-03-08  5:18   ` Upadhyay, Tejas
2024-03-08  4:36 ` [PATCH 2/3] drm/xe/vf: Remove lmtt->ops null check in xe_lmtt_estimate_pt_size Himal Prasad Ghimiray
2024-03-08 14:52   ` Rodrigo Vivi [this message]
2024-03-08 16:22     ` Ghimiray, Himal Prasad
2024-03-11 13:13       ` Michal Wajdeczko
2024-03-11 14:21         ` Lucas De Marchi
2024-03-08  4:36 ` [PATCH 3/3] drm/xe/xe_exec : In xe_exec_ioctl remove deadcode Himal Prasad Ghimiray
2024-03-08  5:27   ` Upadhyay, Tejas
2024-03-08  4:46 ` ✓ CI.Build: success for Minor fixes for errors reported by static analyzer Patchwork
2024-03-08  4:46 ` ✗ CI.Hooks: failure " Patchwork
2024-03-08  4:48 ` ✓ CI.checksparse: success " Patchwork
2024-03-08  5:38 ` ✓ CI.BAT: " Patchwork

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=ZesmInDmDsLY1uPh@intel.com \
    --to=rodrigo.vivi@intel.com \
    --cc=himal.prasad.ghimiray@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    /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 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.