[bug report] drm/amdgpu: Refine CSA related functions

Dan Carpenter dan.carpenter at oracle.com
Fri Nov 23 08:40:45 UTC 2018

Hello Rex Zhu,

The patch 1e256e276221: "drm/amdgpu: Refine CSA related functions"
from Oct 15, 2018, leads to the following static checker warning:

	drivers/gpu/drm/amd/amdgpu/amdgpu_csa.c:49 amdgpu_allocate_static_csa()
	error: uninitialized symbol 'ptr'.

    37  int amdgpu_allocate_static_csa(struct amdgpu_device *adev, struct amdgpu_bo **bo,
    38                                  u32 domain, uint32_t size)
    39  {
    40          int r;
    41          void *ptr;
    43          r = amdgpu_bo_create_kernel(adev, size, PAGE_SIZE,
    44                                  domain, bo,
    45                                  NULL, &ptr);
    46          if (!bo)
We've already dereferenced "bo" at this point so this test doesn't work.
Smatch doesn't complain because it knows that all the caller pass a
valid "bo" pointer...  Anyway probably this should just check if "r" is

    47                  return -ENOMEM;
    49          memset(ptr, 0, size);
This is uninitialized if amdgpu_bo_create_kernel() fails.

    50          return 0;
    51  }

dan carpenter

More information about the amd-gfx mailing list