From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>,
alexander.deucher@amd.com, christian.koenig@amd.com,
amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH 2/2] amdgpu: don't dereference a NULL resource in sysfs code
Date: Thu, 6 Jun 2024 09:14:05 +0200 [thread overview]
Message-ID: <28e46920-df2b-4b0b-b67c-b3750195f2d7@gmail.com> (raw)
In-Reply-To: <20240603084729.15135-2-pierre-eric.pelloux-prayer@amd.com>
Am 03.06.24 um 10:46 schrieb Pierre-Eric Pelloux-Prayer:
> dma_resv_trylock being successful doesn't guarantee that bo->tbo.base.resv
> is not NULL, so check its validity before using it.
>
> Signed-off-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Please make sure that checkpatch doesn't complain about anything.
With that done the patch is Reviewed-by: Christian König
<christian.koenig@amd.com>
Regards,
Christian.
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 63 +++++++++++-----------
> 1 file changed, 33 insertions(+), 30 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> index 1eadcad1856d..6faeb9e4a572 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> @@ -1594,36 +1594,39 @@ u64 amdgpu_bo_print_info(int id, struct amdgpu_bo *bo, struct seq_file *m)
> u64 size;
>
> if (dma_resv_trylock(bo->tbo.base.resv)) {
> -
> - switch (bo->tbo.resource->mem_type) {
> - case TTM_PL_VRAM:
> - if (amdgpu_res_cpu_visible(adev, bo->tbo.resource))
> - placement = "VRAM VISIBLE";
> - else
> - placement = "VRAM";
> - break;
> - case TTM_PL_TT:
> - placement = "GTT";
> - break;
> - case AMDGPU_PL_GDS:
> - placement = "GDS";
> - break;
> - case AMDGPU_PL_GWS:
> - placement = "GWS";
> - break;
> - case AMDGPU_PL_OA:
> - placement = "OA";
> - break;
> - case AMDGPU_PL_PREEMPT:
> - placement = "PREEMPTIBLE";
> - break;
> - case AMDGPU_PL_DOORBELL:
> - placement = "DOORBELL";
> - break;
> - case TTM_PL_SYSTEM:
> - default:
> - placement = "CPU";
> - break;
> + if (!bo->tbo.resource) {
> + placement = "NONE";
> + } else {
> + switch (bo->tbo.resource->mem_type) {
> + case TTM_PL_VRAM:
> + if (amdgpu_res_cpu_visible(adev, bo->tbo.resource))
> + placement = "VRAM VISIBLE";
> + else
> + placement = "VRAM";
> + break;
> + case TTM_PL_TT:
> + placement = "GTT";
> + break;
> + case AMDGPU_PL_GDS:
> + placement = "GDS";
> + break;
> + case AMDGPU_PL_GWS:
> + placement = "GWS";
> + break;
> + case AMDGPU_PL_OA:
> + placement = "OA";
> + break;
> + case AMDGPU_PL_PREEMPT:
> + placement = "PREEMPTIBLE";
> + break;
> + case AMDGPU_PL_DOORBELL:
> + placement = "DOORBELL";
> + break;
> + case TTM_PL_SYSTEM:
> + default:
> + placement = "CPU";
> + break;
> + }
> }
> dma_resv_unlock(bo->tbo.base.resv);
> } else {
next prev parent reply other threads:[~2024-06-06 7:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-03 8:46 [PATCH 1/2] amdgpu: add the amdgpu_vm ptr in the vm_bo_map/unmap events Pierre-Eric Pelloux-Prayer
2024-06-03 8:46 ` [PATCH 2/2] amdgpu: don't dereference a NULL resource in sysfs code Pierre-Eric Pelloux-Prayer
2024-06-06 7:14 ` Christian König [this message]
2024-06-03 9:58 ` [PATCH 1/2] amdgpu: add the amdgpu_vm ptr in the vm_bo_map/unmap events Christian König
2024-06-03 11:52 ` Pierre-Eric Pelloux-Prayer
2024-06-03 14:12 ` Christian König
2024-06-06 6:52 ` Pelloux-Prayer, Pierre-Eric
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=28e46920-df2b-4b0b-b67c-b3750195f2d7@gmail.com \
--to=ckoenig.leichtzumerken@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=pierre-eric.pelloux-prayer@amd.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