[pci:pci/vpd 4/8] drivers/pci/vpd.c:84:4: warning: Value stored to 'tag' is never read [clang-analyzer-deadcode.DeadStores]

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

 




tree: https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git pci/vpd
head:   e916dfbb77159d11ca4b1819c1aec3b59c3e40ab
commit: f4782abc4fa4b1a4d41134f0cf4d549478a89aee [4/8] PCI/VPD: Don't check Large Resource types for validity
:::::: branch date: 18 hours ago
:::::: commit date: 18 hours ago
config: x86_64-randconfig-c001-20210728 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project c49df15c278857adecd12db6bb1cdc96885f7079)
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/helgaas/pci.git/commit/?id=f4782abc4fa4b1a4d41134f0cf4d549478a89aee git remote add pci https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git
        git fetch --no-tags pci pci/vpd
        git checkout f4782abc4fa4b1a4d41134f0cf4d549478a89aee
        # save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 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/target/iscsi/iscsi_target_login.c:1331:3: note: Taking false branch
                   if (iscsi_login_zero_tsih_s1(conn, buffer) < 0)
                   ^
drivers/target/iscsi/iscsi_target_login.c:1353:7: note: Value assigned to field 'sess'
           rc = iscsi_target_locate_portal(np, conn, login);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/target/iscsi/iscsi_target_login.c:1354:6: note: Assuming 'rc' is >= 0
           if (rc < 0) {
               ^~~~~~
drivers/target/iscsi/iscsi_target_login.c:1354:2: note: Taking false branch
           if (rc < 0) {
           ^
drivers/target/iscsi/iscsi_target_login.c:1360:6: note: Assuming field 'sess' is null
           if (conn->sess)
               ^~~~~~~~~~
drivers/target/iscsi/iscsi_target_login.c:1360:2: note: Taking false branch
           if (conn->sess)
           ^
drivers/target/iscsi/iscsi_target_login.c:1365:6: note: Assuming 'tpg' is non-null
           if (!tpg) {
               ^~~~
drivers/target/iscsi/iscsi_target_login.c:1365:2: note: Taking false branch
           if (!tpg) {
           ^
   drivers/target/iscsi/iscsi_target_login.c:1370:6: note: 'zero_tsih' is 1
           if (zero_tsih) {
               ^~~~~~~~~
drivers/target/iscsi/iscsi_target_login.c:1370:2: note: Taking true branch
           if (zero_tsih) {
           ^
drivers/target/iscsi/iscsi_target_login.c:1371:7: note: Calling 'iscsi_login_zero_tsih_s2'
                   if (iscsi_login_zero_tsih_s2(conn) < 0)
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/target/iscsi/iscsi_target_login.c:343:2: note: 'sess' initialized to a null pointer value
           struct iscsi_session *sess = conn->sess;
           ^~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/target/iscsi/iscsi_target_login.c:346:12: note: Access to field 'tpg' results in a dereference of a null pointer (loaded from variable 'sess')
           sess->tpg = conn->tpg;
           ~~~~      ^
drivers/target/iscsi/iscsi_target_login.c:1412:2: warning: Value stored to 'new_sess' is never read [clang-analyzer-deadcode.DeadStores]
           new_sess = false;
           ^          ~~~~~
drivers/target/iscsi/iscsi_target_login.c:1412:2: note: Value stored to 'new_sess' is never read
           new_sess = false;
           ^          ~~~~~
   Suppressed 16 warnings (14 in non-user code, 2 with check filters).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   6 warnings generated.
   Suppressed 6 warnings (6 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.
   7 warnings generated.
   Suppressed 7 warnings (7 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.
   Suppressed 5 warnings (5 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.
   6 warnings generated.
   Suppressed 6 warnings (6 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.
   7 warnings generated.
   Suppressed 7 warnings (7 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.
   6 warnings generated.
   Suppressed 6 warnings (6 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.
   6 warnings generated.
   Suppressed 6 warnings (6 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.
   6 warnings generated.
   Suppressed 6 warnings (6 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.
   6 warnings generated.
   Suppressed 6 warnings (6 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.
   6 warnings generated.
   Suppressed 6 warnings (6 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.
   6 warnings generated.
   Suppressed 6 warnings (6 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.
   7 warnings generated.
   Suppressed 7 warnings (7 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.
   6 warnings generated.
   Suppressed 6 warnings (6 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.
   6 warnings generated.
   Suppressed 6 warnings (6 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.
   6 warnings generated.
   Suppressed 6 warnings (6 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.
   6 warnings generated.
   Suppressed 6 warnings (6 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.
   6 warnings generated.
   Suppressed 6 warnings (6 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.
   7 warnings generated.
drivers/pci/vpd.c:84:4: warning: Value stored to 'tag' is never read [clang-analyzer-deadcode.DeadStores]
                           tag = pci_vpd_lrdt_tag(header);
                           ^     ~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/pci/vpd.c:84:4: note: Value stored to 'tag' is never read
                           tag = pci_vpd_lrdt_tag(header);
                           ^     ~~~~~~~~~~~~~~~~~~~~~~~~
   Suppressed 6 warnings (6 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.
   8 warnings generated.
drivers/pci/setup-bus.c:87:2: warning: Use of memory after it is freed [clang-analyzer-unix.Malloc]
           list_for_each_entry_safe(dev_res, tmp, head, list) {
           ^
include/linux/list.h:716:7: note: expanded from macro 'list_for_each_entry_safe' n = list_next_entry(pos, member); \
                       ^
   include/linux/list.h:555:2: note: expanded from macro 'list_next_entry'
           list_entry((pos)->member.next, typeof(*(pos)), member)
           ^
   include/linux/list.h:511:2: note: expanded from macro 'list_entry'
           container_of(ptr, type, member)
           ^
   include/linux/kernel.h:494:25: note: expanded from macro 'container_of'
void *__mptr = (void *)(ptr); \
                                  ^
drivers/pci/setup-bus.c:1907:6: note: Assuming field 'parent' is non-null
           if (!io_res->parent && align)
               ^~~~~~~~~~~~~~~
   drivers/pci/setup-bus.c:1907:22: note: Left side of '&&' is false
           if (!io_res->parent && align)
                               ^
drivers/pci/setup-bus.c:1911:6: note: Assuming field 'parent' is non-null
           if (!mmio_res->parent && align)
               ^~~~~~~~~~~~~~~~~
   drivers/pci/setup-bus.c:1911:24: note: Left side of '&&' is false
           if (!mmio_res->parent && align)
                                 ^
drivers/pci/setup-bus.c:1915:6: note: Assuming field 'parent' is non-null
           if (!mmio_pref_res->parent && align)
               ^~~~~~~~~~~~~~~~~~~~~~
   drivers/pci/setup-bus.c:1915:29: note: Left side of '&&' is false
           if (!mmio_pref_res->parent && align)
                                      ^
   drivers/pci/setup-bus.c:1923:2: note: Calling 'adjust_bridge_window'
adjust_bridge_window(bridge, io_res, add_list, resource_size(&io));

^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/pci/setup-bus.c:1867:6: note: Assuming field 'parent' is null
           if (res->parent)
               ^~~~~~~~~~~
   drivers/pci/setup-bus.c:1867:2: note: Taking false branch
           if (res->parent)
           ^
drivers/pci/setup-bus.c:1870:6: note: Assuming 'new_size' is not equal to 0
           if (!new_size)
               ^~~~~~~~~
   drivers/pci/setup-bus.c:1870:2: note: Taking false branch
           if (!new_size)
           ^
   drivers/pci/setup-bus.c:1873:6: note: Assuming 'new_size' is <= 'size'
           if (new_size > size) {
               ^~~~~~~~~~~~~~~
   drivers/pci/setup-bus.c:1873:2: note: Taking false branch
           if (new_size > size) {
           ^
   drivers/pci/setup-bus.c:1877:13: note: Assuming 'new_size' is >= 'size'
           } else if (new_size < size) {
                      ^~~~~~~~~~~~~~~
   drivers/pci/setup-bus.c:1877:9: note: Taking false branch
           } else if (new_size < size) {
                  ^
   drivers/pci/setup-bus.c:1884:2: note: Calling 'remove_from_list'
           remove_from_list(add_list, res);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/pci/setup-bus.c:87:2: note: Left side of '&&' is false
           list_for_each_entry_safe(dev_res, tmp, head, list) {
           ^
include/linux/list.h:715:13: note: expanded from macro 'list_for_each_entry_safe' for (pos = list_first_entry(head, typeof(*pos), member), \
                      ^
   include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
           list_entry((ptr)->next, type, member)
           ^
   include/linux/list.h:511:2: note: expanded from macro 'list_entry'
           container_of(ptr, type, member)
           ^
   include/linux/kernel.h:495:61: note: expanded from macro 'container_of'
BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
                                                                      ^
   drivers/pci/setup-bus.c:87:2: note: Taking false branch
           list_for_each_entry_safe(dev_res, tmp, head, list) {
           ^
include/linux/list.h:715:13: note: expanded from macro 'list_for_each_entry_safe' for (pos = list_first_entry(head, typeof(*pos), member), \
                      ^
   include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
           list_entry((ptr)->next, type, member)
           ^
   include/linux/list.h:511:2: note: expanded from macro 'list_entry'
           container_of(ptr, type, member)
           ^
note: (skipping 2 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all) include/linux/compiler_types.h:328:2: note: expanded from macro 'compiletime_assert'

vim +/tag +84 drivers/pci/vpd.c

f0eb77ae6b857bf Bjorn Helgaas 2018-03-19 67 f0eb77ae6b857bf Bjorn Helgaas 2018-03-19 68 /** f0eb77ae6b857bf Bjorn Helgaas 2018-03-19 69 * pci_vpd_size - determine actual size of Vital Product Data
f0eb77ae6b857bf Bjorn Helgaas   2018-03-19   70   * @dev:	pci device struct
f0eb77ae6b857bf Bjorn Helgaas 2018-03-19 71 * @old_size: current assumed size, also maximum allowed size
f0eb77ae6b857bf Bjorn Helgaas   2018-03-19   72   */
f0eb77ae6b857bf Bjorn Helgaas 2018-03-19 73 static size_t pci_vpd_size(struct pci_dev *dev, size_t old_size)
f0eb77ae6b857bf Bjorn Helgaas   2018-03-19   74  {
f0eb77ae6b857bf Bjorn Helgaas   2018-03-19   75  	size_t off = 0;
f0eb77ae6b857bf Bjorn Helgaas 2018-03-19 76 unsigned char header[1+2]; /* 1 byte tag, 2 bytes length */ f0eb77ae6b857bf Bjorn Helgaas 2018-03-19 77 d1df5f3f4cfff88 Heiner Kallweit 2021-04-01 78 while (off < old_size && pci_read_vpd(dev, off, 1, header) == 1) {
f0eb77ae6b857bf Bjorn Helgaas   2018-03-19   79  		unsigned char tag;
036da7445449719 Bjorn Helgaas   2021-07-15   80  		size_t size;
d1df5f3f4cfff88 Heiner Kallweit 2021-04-01 81 f0eb77ae6b857bf Bjorn Helgaas 2018-03-19 82 if (header[0] & PCI_VPD_LRDT) { f0eb77ae6b857bf Bjorn Helgaas 2018-03-19 83 /* Large Resource Data Type Tag */ f0eb77ae6b857bf Bjorn Helgaas 2018-03-19 @84 tag = pci_vpd_lrdt_tag(header); f4782abc4fa4b1a Bjorn Helgaas 2021-07-15 85 if (pci_read_vpd(dev, off + 1, 2, &header[1]) != 2) { 84ec406b429ab10 Bjorn Helgaas 2021-07-15 86 pci_warn(dev, "failed VPD read at offset %zu",
84ec406b429ab10 Bjorn Helgaas   2021-07-15   87  					 off + 1);
f0eb77ae6b857bf Bjorn Helgaas   2018-03-19   88  				return 0;
f0eb77ae6b857bf Bjorn Helgaas   2018-03-19   89  			}
036da7445449719 Bjorn Helgaas 2021-07-15 90 size = pci_vpd_lrdt_size(header); 036da7445449719 Bjorn Helgaas 2021-07-15 91 036da7445449719 Bjorn Helgaas 2021-07-15 92 /* f4782abc4fa4b1a Bjorn Helgaas 2021-07-15 93 * Missing EEPROM may read as 0xff. Length of f4782abc4fa4b1a Bjorn Helgaas 2021-07-15 94 * 0xffff (65535) cannot be valid because VPD can't
f4782abc4fa4b1a Bjorn Helgaas   2021-07-15   95  			 * be that large.
036da7445449719 Bjorn Helgaas   2021-07-15   96  			 */
036da7445449719 Bjorn Helgaas 2021-07-15 97 if (size > PCI_VPD_MAX_SIZE)
036da7445449719 Bjorn Helgaas   2021-07-15   98  				goto error;
f4782abc4fa4b1a Bjorn Helgaas 2021-07-15 99 036da7445449719 Bjorn Helgaas 2021-07-15 100 off += PCI_VPD_LRDT_TAG_SIZE + size;
f0eb77ae6b857bf Bjorn Helgaas   2018-03-19  101  		} else {
f0eb77ae6b857bf Bjorn Helgaas 2018-03-19 102 /* Short Resource Data Type Tag */ f0eb77ae6b857bf Bjorn Helgaas 2018-03-19 103 tag = pci_vpd_srdt_tag(header); 036da7445449719 Bjorn Helgaas 2021-07-15 104 size = pci_vpd_srdt_size(header); 036da7445449719 Bjorn Helgaas 2021-07-15 105 036da7445449719 Bjorn Helgaas 2021-07-15 106 /* 036da7445449719 Bjorn Helgaas 2021-07-15 107 * Missing EEPROM may read as 0x00. A small item 036da7445449719 Bjorn Helgaas 2021-07-15 108 * must be at least 2 bytes.
036da7445449719 Bjorn Helgaas   2021-07-15  109  			 */
036da7445449719 Bjorn Helgaas   2021-07-15  110  			if (size == 0)
036da7445449719 Bjorn Helgaas   2021-07-15  111  				goto error;
036da7445449719 Bjorn Helgaas 2021-07-15 112 036da7445449719 Bjorn Helgaas 2021-07-15 113 off += PCI_VPD_SRDT_TAG_SIZE + size; f0eb77ae6b857bf Bjorn Helgaas 2018-03-19 114 if (tag == PCI_VPD_STIN_END) /* End tag descriptor */
f0eb77ae6b857bf Bjorn Helgaas   2018-03-19  115  				return off;
f0eb77ae6b857bf Bjorn Helgaas   2018-03-19  116  		}
f0eb77ae6b857bf Bjorn Helgaas   2018-03-19  117  	}
f0eb77ae6b857bf Bjorn Helgaas   2018-03-19  118  	return 0;
036da7445449719 Bjorn Helgaas 2021-07-15 119 036da7445449719 Bjorn Helgaas 2021-07-15 120 error: 036da7445449719 Bjorn Helgaas 2021-07-15 121 pci_info(dev, "invalid VPD tag %#04x at offset %zu%s\n", 036da7445449719 Bjorn Helgaas 2021-07-15 122 header[0], off, off == 0 ? 036da7445449719 Bjorn Helgaas 2021-07-15 123 "; assume missing optional EEPROM" : "");
036da7445449719 Bjorn Helgaas   2021-07-15  124  	return 0;
f0eb77ae6b857bf Bjorn Helgaas   2018-03-19  125  }
f0eb77ae6b857bf Bjorn Helgaas   2018-03-19  126
:::::: The code at line 84 was first introduced by commit
:::::: f0eb77ae6b857bf8118f7a8ee0a8ba076feed70d PCI/VPD: Move VPD access code to vpd.c

:::::: TO: Bjorn Helgaas <bhelgaas@xxxxxxxxxx>
:::::: CC: Bjorn Helgaas <helgaas@xxxxxxxxxx>

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

Attachment: .config.gz
Description: application/gzip

_______________________________________________
kbuild mailing list -- kbuild@xxxxxxxxxxxx
To unsubscribe send an email to kbuild-leave@xxxxxxxxxxxx


[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux