From: Dan Carpenter <dan.carpenter@linaro.org>
To: sreekant.somasekharan@amd.com
Cc: amd-gfx@lists.freedesktop.org
Subject: [bug report] drm/amdkfd: mark GFX12 system and peer GPU memory mappings as MTYPE_NC
Date: Sat, 4 May 2024 22:35:13 +0300 [thread overview]
Message-ID: <52b003ec-a570-49f5-9150-79f8feb46339@moroto.mountain> (raw)
Hello Sreekant Somasekharan,
This is a semi-automatic email about new static checker warnings.
Commit 628e1ace2379 ("drm/amdkfd: mark GFX12 system and peer GPU
memory mappings as MTYPE_NC") from Mar 26, 2024, leads to the
following Smatch complaint:
drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c:518 gmc_v12_0_get_vm_pte()
warn: variable dereferenced before check 'bo' (see line 500)
drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c
499 struct amdgpu_bo *bo = mapping->bo_va->base.bo;
500 struct amdgpu_device *bo_adev = amdgpu_ttm_adev(bo->tbo.bdev);
^^^^
501 bool coherent = bo->flags & AMDGPU_GEM_CREATE_COHERENT;
^^^^^^^^^
502 bool is_system = bo->tbo.resource->mem_type == TTM_PL_SYSTEM;
^^^^^^^
The patch adds unchecked dereferences.
503
504
505 *flags &= ~AMDGPU_PTE_EXECUTABLE;
506 *flags |= mapping->flags & AMDGPU_PTE_EXECUTABLE;
507
508 *flags &= ~AMDGPU_PTE_MTYPE_GFX12_MASK;
509 *flags |= (mapping->flags & AMDGPU_PTE_MTYPE_GFX12_MASK);
510
511 if (mapping->flags & AMDGPU_PTE_PRT_GFX12) {
512 *flags |= AMDGPU_PTE_PRT_GFX12;
513 *flags |= AMDGPU_PTE_SNOOPED;
514 *flags |= AMDGPU_PTE_SYSTEM;
515 *flags &= ~AMDGPU_PTE_VALID;
516 }
517
518 if (bo && bo->flags & (AMDGPU_GEM_CREATE_COHERENT |
^^
But previously we assumed bo could be NULL.
519 AMDGPU_GEM_CREATE_UNCACHED))
520 *flags = (*flags & ~AMDGPU_PTE_MTYPE_GFX12_MASK) |
regards,
dan carpenter
reply other threads:[~2024-05-06 10:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=52b003ec-a570-49f5-9150-79f8feb46339@moroto.mountain \
--to=dan.carpenter@linaro.org \
--cc=amd-gfx@lists.freedesktop.org \
--cc=sreekant.somasekharan@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 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.