[bug report] drm/amdkfd: mark GFX12 system and peer GPU memory mappings as MTYPE_NC

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux