Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Nirmoy Das <nirmoy.das@linux.intel.com>
To: Rodrigo Vivi <rodrigo.vivi@intel.com>, intel-xe@lists.freedesktop.org
Cc: "Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"José Roberto de Souza" <jose.souza@intel.com>
Subject: Re: [PATCH] drm/xe: Protect devcoredump_free
Date: Wed, 3 Apr 2024 17:47:14 +0200	[thread overview]
Message-ID: <da259b55-5bbe-4f1b-82cc-4399d2514c14@linux.intel.com> (raw)
In-Reply-To: <20240403145054.97414-1-rodrigo.vivi@intel.com>

Hi Rodrigo,

On 4/3/2024 4:50 PM, Rodrigo Vivi wrote:
> While we don't have the full flow protection when devcoredump
> is accessed after device unbind. Let's at least for now
> protect against null dereference:
>
> [  422.766508] KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007]
> [  423.119584] RIP: 0010:xe_vm_snapshot_free+0x30/0x180 [xe]
>
> While at it, I also fixed a non-standard code-declaration block
> on the similar function of xe_guc_submit.
>
> Fixes: e5f661bb56d4 ("drm/xe/devcoredump: Print errno if VM snapshot was not captured")
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Cc: José Roberto de Souza <jose.souza@intel.com>
> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> ---
>   drivers/gpu/drm/xe/xe_guc_submit.c | 1 +
>   drivers/gpu/drm/xe/xe_vm.c         | 2 +-
>   2 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c b/drivers/gpu/drm/xe/xe_guc_submit.c
> index f42f1b567067..6e32f9ce4eb5 100644
> --- a/drivers/gpu/drm/xe/xe_guc_submit.c
> +++ b/drivers/gpu/drm/xe/xe_guc_submit.c
> @@ -1961,6 +1961,7 @@ xe_guc_exec_queue_snapshot_print(struct xe_guc_submit_exec_queue_snapshot *snaps
>   void xe_guc_exec_queue_snapshot_free(struct xe_guc_submit_exec_queue_snapshot *snapshot)
>   {
>   	int i;
> +
>   	if (!snapshot)
>   		return;
>   
> diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
> index f4bfb2705956..ccb2e1c67c2c 100644
> --- a/drivers/gpu/drm/xe/xe_vm.c
> +++ b/drivers/gpu/drm/xe/xe_vm.c
> @@ -3514,7 +3514,7 @@ void xe_vm_snapshot_free(struct xe_vm_snapshot *snap)
>   {
>   	unsigned long i;
>   
> -	if (IS_ERR(snap))
> +	if (!snap || IS_ERR(snap))
>   		return;

You can use IS_ERR_OR_NULL() here.


Regards,

Nirmoy

>   
>   	for (i = 0; i < snap->num_snaps; i++) {

  parent reply	other threads:[~2024-04-03 15:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-03 14:50 [PATCH] drm/xe: Protect devcoredump_free Rodrigo Vivi
2024-04-03 15:14 ` ✓ CI.Patch_applied: success for " Patchwork
2024-04-03 15:14 ` ✓ CI.checkpatch: " Patchwork
2024-04-03 15:15 ` ✓ CI.KUnit: " Patchwork
2024-04-03 15:23 ` [PATCH] " Souza, Jose
2024-04-03 15:37 ` ✓ CI.Build: success for " Patchwork
2024-04-03 15:40 ` ✓ CI.Hooks: " Patchwork
2024-04-03 15:41 ` ✓ CI.checksparse: " Patchwork
2024-04-03 15:47 ` Nirmoy Das [this message]
2024-04-03 16:15 ` ✓ 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=da259b55-5bbe-4f1b-82cc-4399d2514c14@linux.intel.com \
    --to=nirmoy.das@linux.intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jose.souza@intel.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=rodrigo.vivi@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