drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:236:9: warning: The left expression of the compound assignment is an uninitialized value. The computed value will also be garbage [clang-analyzer-core.uninitialized.Assign]

From: kernel test robot
Date: Sat Nov 13 2021 - 10:11:26 EST


tree: https://github.com/0day-ci/linux/commits/Arunpravin/Enable-buddy-memory-manager-support/20210921-032602
head: 71b3775a5ce7b59e8c5292ae438284e8569c9e9f
commit: 71b3775a5ce7b59e8c5292ae438284e8569c9e9f Add drm buddy manager support to amdgpu driver
date: 7 weeks ago
config: riscv-randconfig-c006-20210927 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project dc6e8dfdfe7efecfda318d43a06fae18b40eb498)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install riscv cross compiling tool for clang build
# apt-get install binutils-riscv64-linux-gnu
# https://github.com/0day-ci/linux/commit/71b3775a5ce7b59e8c5292ae438284e8569c9e9f
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Arunpravin/Enable-buddy-memory-manager-support/20210921-032602
git checkout 71b3775a5ce7b59e8c5292ae438284e8569c9e9f
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv clang-analyzer

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>


clang-analyzer warnings: (new ones prefixed by >>)

>> drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:236:9: warning: The left expression of the compound assignment is an uninitialized value. The computed value will also be garbage [clang-analyzer-core.uninitialized.Assign]
usage += amdgpu_vram_mgr_vis_size(adev, block);
~~~~~ ^
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:227:2: note: 'usage' declared without an initial value
u64 usage;
^~~~~~~~~
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:236:9: note: The left expression of the compound assignment is an uninitialized value. The computed value will also be garbage
usage += amdgpu_vram_mgr_vis_size(adev, block);
~~~~~ ^
>> drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:238:2: warning: Undefined or garbage value returned to caller [clang-analyzer-core.uninitialized.UndefReturn]
return usage;
^ ~~~~~


vim +236 drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c

3c848bb38aca1f Christian König 2017-08-07 212
5e9244ff585239 Michel Dänzer 2018-06-12 213 /**
ddc21af4d0f37f Michel Dänzer 2018-07-11 214 * amdgpu_vram_mgr_bo_visible_size - CPU visible BO size
5e9244ff585239 Michel Dänzer 2018-06-12 215 *
5e9244ff585239 Michel Dänzer 2018-06-12 216 * @bo: &amdgpu_bo buffer object (must be in VRAM)
5e9244ff585239 Michel Dänzer 2018-06-12 217 *
5e9244ff585239 Michel Dänzer 2018-06-12 218 * Returns:
ddc21af4d0f37f Michel Dänzer 2018-07-11 219 * How much of the given &amdgpu_bo buffer object lies in CPU visible VRAM.
5e9244ff585239 Michel Dänzer 2018-06-12 220 */
ddc21af4d0f37f Michel Dänzer 2018-07-11 221 u64 amdgpu_vram_mgr_bo_visible_size(struct amdgpu_bo *bo)
5e9244ff585239 Michel Dänzer 2018-06-12 222 {
7303b39e46b2f5 Michel Dänzer 2018-06-14 223 struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
cb1c81467af355 Christian König 2021-04-30 224 struct ttm_resource *res = bo->tbo.resource;
71b3775a5ce7b5 Arunpravin 2021-09-21 225 struct amdgpu_vram_mgr_node *vnode = to_amdgpu_vram_mgr_node(res);
71b3775a5ce7b5 Arunpravin 2021-09-21 226 struct drm_buddy_block *block;
ddc21af4d0f37f Michel Dänzer 2018-07-11 227 u64 usage;
5e9244ff585239 Michel Dänzer 2018-06-12 228
9735bf1930e658 Michel Dänzer 2018-06-15 229 if (amdgpu_gmc_vram_full_visible(&adev->gmc))
ddc21af4d0f37f Michel Dänzer 2018-07-11 230 return amdgpu_bo_size(bo);
7303b39e46b2f5 Michel Dänzer 2018-06-14 231
cb1c81467af355 Christian König 2021-04-30 232 if (res->start >= adev->gmc.visible_vram_size >> PAGE_SHIFT)
ddc21af4d0f37f Michel Dänzer 2018-07-11 233 return 0;
7303b39e46b2f5 Michel Dänzer 2018-06-14 234
71b3775a5ce7b5 Arunpravin 2021-09-21 235 list_for_each_entry(block, &vnode->blocks, link)
71b3775a5ce7b5 Arunpravin 2021-09-21 @236 usage += amdgpu_vram_mgr_vis_size(adev, block);
7303b39e46b2f5 Michel Dänzer 2018-06-14 237
7303b39e46b2f5 Michel Dänzer 2018-06-14 @238 return usage;
5e9244ff585239 Michel Dänzer 2018-06-12 239 }
5e9244ff585239 Michel Dänzer 2018-06-12 240

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip