[linux-stable-rc:linux-4.9.y 1986/2294] drivers/iommu/amd_iommu.c:1335:6: warning: variable 'flags' is used uninitialized whenever 'if' condition is true

From: kernel test robot
Date: Sat Jul 03 2021 - 01:41:38 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.9.y
head: f44373a3e7a37999a7506c79891abbb8f1318471
commit: 1d648460d7c513b1f500b7887c9af98285340432 [1986/2294] iommu/amd: Fix sleeping in atomic in increase_address_space()
config: x86_64-randconfig-a014-20210703 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project cb5de7c813f976dd458bd2a7f40702ba648bf650)
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 x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git/commit/?id=1d648460d7c513b1f500b7887c9af98285340432
git remote add linux-stable-rc https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
git fetch --no-tags linux-stable-rc linux-4.9.y
git checkout 1d648460d7c513b1f500b7887c9af98285340432
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64

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

All warnings (new ones prefixed by >>):

>> drivers/iommu/amd_iommu.c:1335:6: warning: variable 'flags' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (!pte)
^~~~
drivers/iommu/amd_iommu.c:1352:40: note: uninitialized use occurs here
spin_unlock_irqrestore(&domain->lock, flags);
^~~~~
drivers/iommu/amd_iommu.c:1335:2: note: remove the 'if' if its condition is always false
if (!pte)
^~~~~~~~~
drivers/iommu/amd_iommu.c:1331:21: note: initialize the variable 'flags' to silence this warning
unsigned long flags;
^
= 0
drivers/iommu/amd_iommu.c:2474:13: warning: variable 'flush_addr' set but not used [-Wunused-but-set-variable]
dma_addr_t flush_addr;
^
2 warnings generated.


vim +1335 drivers/iommu/amd_iommu.c

1315
1316 /****************************************************************************
1317 *
1318 * The functions below are used the create the page table mappings for
1319 * unity mapped regions.
1320 *
1321 ****************************************************************************/
1322
1323 /*
1324 * This function is used to add another level to an IO page table. Adding
1325 * another level increases the size of the address space by 9 bits to a size up
1326 * to 64 bits.
1327 */
1328 static void increase_address_space(struct protection_domain *domain,
1329 gfp_t gfp)
1330 {
1331 unsigned long flags;
1332 u64 *pte;
1333
1334 pte = (void *)get_zeroed_page(gfp);
> 1335 if (!pte)
1336 goto out;
1337
1338 spin_lock_irqsave(&domain->lock, flags);
1339
1340 if (WARN_ON_ONCE(domain->mode == PAGE_MODE_6_LEVEL))
1341 /* address space already 64 bit large */
1342 goto out;
1343
1344 *pte = PM_LEVEL_PDE(domain->mode,
1345 virt_to_phys(domain->pt_root));
1346 domain->pt_root = pte;
1347 domain->mode += 1;
1348 domain->updated = true;
1349 pte = NULL;
1350
1351 out:
1352 spin_unlock_irqrestore(&domain->lock, flags);
1353 free_page((unsigned long)pte);
1354
1355 return;
1356 }
1357

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

Attachment: .config.gz
Description: application/gzip