All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Everest K.C. <everestkc@everestkc.com.np>
Cc: <lucas.demarchi@intel.com>, <thomas.hellstrom@linux.intel.com>,
	<maarten.lankhorst@linux.intel.com>, <mripard@kernel.org>,
	<tzimmermann@suse.de>, <airlied@gmail.com>, <simona@ffwll.ch>,
	<skhan@linuxfoundation.org>, <dan.carpenter@linaro.org>,
	<michal.wajdeczko@intel.com>, <intel-xe@lists.freedesktop.org>,
	<dri-devel@lists.freedesktop.org>,
	<kernel-janitors@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH V4] drm/xe/guc: Fix dereference before NULL check
Date: Wed, 23 Oct 2024 16:11:25 -0400	[thread overview]
Message-ID: <ZxlYbVOLPQv-oWrv@intel.com> (raw)
In-Reply-To: <20241010165801.3913-1-everestkc@everestkc.com.np>

On Thu, Oct 10, 2024 at 10:57:59AM -0600, Everest K.C. wrote:
> The pointer list->list is dereferenced before the NULL check.
> Fix this by moving the NULL check outside the for loop, so that
> the check is performed before the dereferencing.
> The list->list pointer cannot be NULL so this has no effect on runtime.
> It's just a correctness issue.
> 
> This issue was reported by Coverity Scan.
> https://scan7.scan.coverity.com/#/project-view/51525/11354?selectedIssue=1600335
> 
> Fixes: 0f1fdf559225 ("drm/xe/guc: Save manual engine capture into capture list")
> Signed-off-by: Everest K.C. <everestkc@everestkc.com.np>
> Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> V3 -> V4: - Corrected the Fixes tag
>           - Added Reviewed-by tag

For some reason it looks like nor CI nor lore has this v4 version.

could you please resubmit it?

> V2 -> V3: - Changed Null to NULL in the changelog
>           - Corrected typo in the changelong
>           - Added more description to the changelong
> 	  - Fixed the link for Coverity Report
> 	  - Removed the space after the Fixes tag
> V1 -> V2: - Combined the `!list->list` check in preexisting if statement
> 	  - Added Fixes tag 
> 	  - Added the link to the Coverity Scan report 
> 
>  drivers/gpu/drm/xe/xe_guc_capture.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_guc_capture.c b/drivers/gpu/drm/xe/xe_guc_capture.c
> index 41262bda20ed..947c3a6d0e5a 100644
> --- a/drivers/gpu/drm/xe/xe_guc_capture.c
> +++ b/drivers/gpu/drm/xe/xe_guc_capture.c
> @@ -1531,7 +1531,7 @@ read_reg_to_node(struct xe_hw_engine *hwe, const struct __guc_mmio_reg_descr_gro
>  {
>  	int i;
>  
> -	if (!list || list->num_regs == 0)
> +	if (!list || !list->list || list->num_regs == 0)
>  		return;
>  
>  	if (!regs)
> @@ -1541,9 +1541,6 @@ read_reg_to_node(struct xe_hw_engine *hwe, const struct __guc_mmio_reg_descr_gro
>  		struct __guc_mmio_reg_descr desc = list->list[i];
>  		u32 value;
>  
> -		if (!list->list)
> -			return;
> -
>  		if (list->type == GUC_STATE_CAPTURE_TYPE_ENGINE_INSTANCE) {
>  			value = xe_hw_engine_mmio_read32(hwe, desc.reg);
>  		} else {
> -- 
> 2.43.0
> 

  reply	other threads:[~2024-10-23 20:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-10 16:57 [PATCH V4] drm/xe/guc: Fix dereference before NULL check Everest K.C.
2024-10-23 20:11 ` Rodrigo Vivi [this message]
2024-10-23 20:59   ` Everest K.C.

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=ZxlYbVOLPQv-oWrv@intel.com \
    --to=rodrigo.vivi@intel.com \
    --cc=airlied@gmail.com \
    --cc=dan.carpenter@linaro.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=everestkc@everestkc.com.np \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lucas.demarchi@intel.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=michal.wajdeczko@intel.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=skhan@linuxfoundation.org \
    --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 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.