All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: kbuild@lists.01.org
Subject: drivers/pci/endpoint/pci-epc-mem.c:29:7: warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign]
Date: Mon, 23 Aug 2021 10:25:02 +0800	[thread overview]
Message-ID: <202108231056.QTcR6K1Y-lkp@intel.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 14551 bytes --]

CC: clang-built-linux(a)googlegroups.com
CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Jakub Jelinek <jakub@redhat.com>
CC: "Peter Zijlstra (Intel)" <peterz@infradead.org>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: Linux Memory Management List <linux-mm@kvack.org>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   e22ce8eb631bdc47a4a4ea7ecf4e4ba499db4f93
commit: 2f78788b55baa3410b1ec91a576286abe1ad4d6a ilog2: improve ilog2 for constant arguments
date:   8 months ago
:::::: branch date: 5 hours ago
:::::: commit date: 8 months ago
config: arm-randconfig-c002-20210820 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project d9c5613e856cf2addfbf892fc4c1ce9ef9feceaa)
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 arm cross compiling tool for clang build
        # apt-get install binutils-arm-linux-gnueabi
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=2f78788b55baa3410b1ec91a576286abe1ad4d6a
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 2f78788b55baa3410b1ec91a576286abe1ad4d6a
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm clang-analyzer 

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


clang-analyzer warnings: (new ones prefixed by >>)
           ^
   security/keys/keyring.c:1611:6: note: 'ret' is >= 0
           if (ret < 0)
               ^~~
   security/keys/keyring.c:1611:2: note: Taking false branch
           if (ret < 0)
           ^
   security/keys/keyring.c:1613:8: note: Calling '__key_link_begin'
           ret = __key_link_begin(to_keyring, &key->index_key, &to_edit);
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   security/keys/keyring.c:1299:2: note: Taking false branch
           kenter("%d,%s,%s,",
           ^
   security/keys/internal.h:34:2: note: expanded from macro 'kenter'
           no_printk(KERN_DEBUG "==> %s("FMT")\n", __func__, ##__VA_ARGS__)
           ^
   include/linux/printk.h:139:2: note: expanded from macro 'no_printk'
           if (0)                                          \
           ^
   security/keys/keyring.c:1302:9: note: Assuming field 'desc_len' is not equal to 0
           BUG_ON(index_key->desc_len == 0);
                  ^
   include/asm-generic/bug.h:183:45: note: expanded from macro 'BUG_ON'
   #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
                                               ^~~~~~~~~
   include/linux/compiler.h:78:42: note: expanded from macro 'unlikely'
   # define unlikely(x)    __builtin_expect(!!(x), 0)
                                               ^
   security/keys/keyring.c:1302:2: note: Taking false branch
           BUG_ON(index_key->desc_len == 0);
           ^
   include/asm-generic/bug.h:183:32: note: expanded from macro 'BUG_ON'
   #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
                                  ^
   security/keys/keyring.c:1302:2: note: Loop condition is false.  Exiting loop
           BUG_ON(index_key->desc_len == 0);
           ^
   include/asm-generic/bug.h:183:27: note: expanded from macro 'BUG_ON'
   #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
                             ^
   security/keys/keyring.c:1303:2: note: Taking false branch
           BUG_ON(*_edit != NULL);
           ^
   include/asm-generic/bug.h:183:32: note: expanded from macro 'BUG_ON'
   #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
                                  ^
   security/keys/keyring.c:1303:2: note: Loop condition is false.  Exiting loop
           BUG_ON(*_edit != NULL);
           ^
   include/asm-generic/bug.h:183:27: note: expanded from macro 'BUG_ON'
   #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
                             ^
   security/keys/keyring.c:1305:2: note: Null pointer value stored to 'to_edit'
           *_edit = NULL;
           ^~~~~~~~~~~~~
   security/keys/keyring.c:1308:6: note: Assuming the condition is false
           if (test_bit(KEY_FLAG_REVOKED, &keyring->flags))
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   security/keys/keyring.c:1308:2: note: Taking false branch
           if (test_bit(KEY_FLAG_REVOKED, &keyring->flags))
           ^
   security/keys/keyring.c:1318:2: note: Taking true branch
           if (IS_ERR(edit)) {
           ^
   security/keys/keyring.c:1320:3: note: Control jumps to line 1340
                   goto error;
                   ^
   security/keys/keyring.c:1340:2: note: Taking false branch
           kleave(" = %d", ret);
           ^
   security/keys/internal.h:36:2: note: expanded from macro 'kleave'
           no_printk(KERN_DEBUG "<== %s()"FMT"\n", __func__, ##__VA_ARGS__)
           ^
   include/linux/printk.h:139:2: note: expanded from macro 'no_printk'
           if (0)                                          \
           ^
   security/keys/keyring.c:1613:8: note: Returning from '__key_link_begin'
           ret = __key_link_begin(to_keyring, &key->index_key, &to_edit);
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   security/keys/keyring.c:1614:6: note: 'ret' is >= 0
           if (ret < 0)
               ^~~
   security/keys/keyring.c:1614:2: note: Taking false branch
           if (ret < 0)
           ^
   security/keys/keyring.c:1618:6: note: Access to field 'dead_leaf' results in a dereference of a null pointer (loaded from variable 'to_edit')
           if (to_edit->dead_leaf && (flags & KEYCTL_MOVE_EXCL))
               ^~~~~~~
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   2 warnings generated.
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   2 warnings generated.
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   2 warnings generated.
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   3 warnings generated.
>> drivers/pci/endpoint/pci-epc-mem.c:29:7: warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign]
           size >>= page_shift;
                ^
   drivers/pci/endpoint/pci-epc-mem.c:244:7: note: 'mem' is non-null
           if (!mem) {
                ^~~
   drivers/pci/endpoint/pci-epc-mem.c:244:2: note: Taking false branch
           if (!mem) {
           ^
   drivers/pci/endpoint/pci-epc-mem.c:250:15: note: '?' condition is false
           page_shift = ilog2(page_size);
                        ^
   include/linux/log2.h:158:2: note: expanded from macro 'ilog2'
           __builtin_constant_p(n) ?       \
           ^
   drivers/pci/endpoint/pci-epc-mem.c:250:15: note: '?' condition is true
           page_shift = ilog2(page_size);
                        ^
   include/linux/log2.h:161:2: note: expanded from macro 'ilog2'
           (sizeof(n) <= 4) ?              \
           ^
   drivers/pci/endpoint/pci-epc-mem.c:254:10: note: Calling 'pci_epc_mem_get_order'
           order = pci_epc_mem_get_order(mem, size);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/pci/endpoint/pci-epc-mem.c:26:28: note: '?' condition is false
           unsigned int page_shift = ilog2(mem->window.page_size);
                                     ^
   include/linux/log2.h:158:2: note: expanded from macro 'ilog2'
           __builtin_constant_p(n) ?       \
           ^
   drivers/pci/endpoint/pci-epc-mem.c:26:28: note: '?' condition is true
           unsigned int page_shift = ilog2(mem->window.page_size);
                                     ^
   include/linux/log2.h:161:2: note: expanded from macro 'ilog2'
           (sizeof(n) <= 4) ?              \
           ^
   drivers/pci/endpoint/pci-epc-mem.c:26:28: note: Calling '__ilog2_u32'
           unsigned int page_shift = ilog2(mem->window.page_size);
                                     ^
   include/linux/log2.h:162:2: note: expanded from macro 'ilog2'
           __ilog2_u32(n) :                \
           ^~~~~~~~~~~~~~
   include/linux/log2.h:24:2: note: Returning the value -1
           return fls(n) - 1;
           ^~~~~~~~~~~~~~~~~
   drivers/pci/endpoint/pci-epc-mem.c:26:28: note: Returning from '__ilog2_u32'
           unsigned int page_shift = ilog2(mem->window.page_size);
                                     ^
   include/linux/log2.h:162:2: note: expanded from macro 'ilog2'
           __ilog2_u32(n) :                \
           ^~~~~~~~~~~~~~
   drivers/pci/endpoint/pci-epc-mem.c:26:2: note: 'page_shift' initialized to 4294967295
           unsigned int page_shift = ilog2(mem->window.page_size);
           ^~~~~~~~~~~~~~~~~~~~~~~
   drivers/pci/endpoint/pci-epc-mem.c:29:7: note: Assigned value is garbage or undefined
           size >>= page_shift;
                ^   ~~~~~~~~~~
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   2 warnings generated.
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   mm/page-writeback.c:1408:14: warning: The result of the left shift is undefined because the right operand is negative [clang-analyzer-core.UndefinedBinaryOperatorResult]
                   return 1UL << (ilog2(thresh - dirty) >> 1);
                              ^
   mm/page-writeback.c:1885:6: note: Assuming the condition is false
           if (!(bdi->capabilities & BDI_CAP_WRITEBACK))
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   mm/page-writeback.c:1885:2: note: Taking false branch
           if (!(bdi->capabilities & BDI_CAP_WRITEBACK))
           ^
   mm/page-writeback.c:1888:2: note: Taking false branch
           if (inode_cgwb_enabled(inode))
           ^
   mm/page-writeback.c:1890:7: note: 'wb' is null
           if (!wb)
                ^~
   mm/page-writeback.c:1890:2: note: Taking true branch
           if (!wb)
           ^
   mm/page-writeback.c:1894:6: note: Assuming field 'dirty_exceeded' is 0
           if (wb->dirty_exceeded)
               ^~~~~~~~~~~~~~~~~~
   mm/page-writeback.c:1894:2: note: Taking false branch
           if (wb->dirty_exceeded)
           ^
   mm/page-writeback.c:1897:2: note: Loop condition is false.  Exiting loop
           preempt_disable();
           ^
   include/linux/preempt.h:171:27: note: expanded from macro 'preempt_disable'
   #define preempt_disable() \
                             ^
   mm/page-writeback.c:1904:7: note: Loop condition is false.  Exiting loop
           p =  this_cpu_ptr(&bdp_ratelimits);
                ^
   include/linux/percpu-defs.h:265:27: note: expanded from macro 'this_cpu_ptr'
   #define this_cpu_ptr(ptr)       raw_cpu_ptr(ptr)

vim +29 drivers/pci/endpoint/pci-epc-mem.c

5e8cb4033807e3 Kishon Vijay Abraham I 2017-04-10  14  
5e8cb4033807e3 Kishon Vijay Abraham I 2017-04-10  15  /**
52c9285d47459c Kishon Vijay Abraham I 2017-08-18  16   * pci_epc_mem_get_order() - determine the allocation order of a memory size
52c9285d47459c Kishon Vijay Abraham I 2017-08-18  17   * @mem: address space of the endpoint controller
52c9285d47459c Kishon Vijay Abraham I 2017-08-18  18   * @size: the size for which to get the order
52c9285d47459c Kishon Vijay Abraham I 2017-08-18  19   *
52c9285d47459c Kishon Vijay Abraham I 2017-08-18  20   * Reimplement get_order() for mem->page_size since the generic get_order
52c9285d47459c Kishon Vijay Abraham I 2017-08-18  21   * always gets order with a constant PAGE_SIZE.
52c9285d47459c Kishon Vijay Abraham I 2017-08-18  22   */
52c9285d47459c Kishon Vijay Abraham I 2017-08-18  23  static int pci_epc_mem_get_order(struct pci_epc_mem *mem, size_t size)
52c9285d47459c Kishon Vijay Abraham I 2017-08-18  24  {
52c9285d47459c Kishon Vijay Abraham I 2017-08-18  25  	int order;
d45e3c1a5979ef Lad Prabhakar          2020-05-07  26  	unsigned int page_shift = ilog2(mem->window.page_size);
52c9285d47459c Kishon Vijay Abraham I 2017-08-18  27  
52c9285d47459c Kishon Vijay Abraham I 2017-08-18  28  	size--;
52c9285d47459c Kishon Vijay Abraham I 2017-08-18 @29  	size >>= page_shift;
52c9285d47459c Kishon Vijay Abraham I 2017-08-18  30  #if BITS_PER_LONG == 32
52c9285d47459c Kishon Vijay Abraham I 2017-08-18  31  	order = fls(size);
52c9285d47459c Kishon Vijay Abraham I 2017-08-18  32  #else
52c9285d47459c Kishon Vijay Abraham I 2017-08-18  33  	order = fls64(size);
52c9285d47459c Kishon Vijay Abraham I 2017-08-18  34  #endif
52c9285d47459c Kishon Vijay Abraham I 2017-08-18  35  	return order;
52c9285d47459c Kishon Vijay Abraham I 2017-08-18  36  }
52c9285d47459c Kishon Vijay Abraham I 2017-08-18  37  

:::::: The code at line 29 was first introduced by commit
:::::: 52c9285d47459cf241e144c7d8ef15941ba1b181 PCI: endpoint: Add support for configurable page size

:::::: TO: Kishon Vijay Abraham I <kishon@ti.com>
:::::: CC: Bjorn Helgaas <bhelgaas@google.com>

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

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 32061 bytes --]

             reply	other threads:[~2021-08-23  2:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-23  2:25 kernel test robot [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-09-19 12:19 drivers/pci/endpoint/pci-epc-mem.c:29:7: warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign] kernel test robot
2021-11-28  3:46 kernel test robot
2021-11-30  2:09 kernel test robot
2021-12-08  6:12 kernel test robot

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=202108231056.QTcR6K1Y-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=kbuild@lists.01.org \
    /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.