[linux-nvme:nvme-5.13 4/4] drivers/nvme/host/multipath.c:810:6: warning: variable 'error' is used uninitialized whenever 'if' condition is true

kernel test robot lkp at intel.com
Mon May 10 04:43:10 PDT 2021


tree:   git://git.infradead.org/nvme.git nvme-5.13
head:   8b951d3a91bdd748db10df3ad020257e49dd97b0
commit: 8b951d3a91bdd748db10df3ad020257e49dd97b0 [4/4] nvme-multipath: fix double initialization of ANA state
config: s390-randconfig-r013-20210510 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 492173d42b32cb91d5d0d72d5ed84fcab80d059a)
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 s390 cross compiling tool for clang build
        # apt-get install binutils-s390x-linux-gnu
        git remote add linux-nvme git://git.infradead.org/nvme.git
        git fetch --no-tags linux-nvme nvme-5.13
        git checkout 8b951d3a91bdd748db10df3ad020257e49dd97b0
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=s390 

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

All warnings (new ones prefixed by >>):

   In file included from drivers/nvme/host/multipath.c:6:
   In file included from include/linux/backing-dev.h:15:
   In file included from include/linux/blkdev.h:26:
   In file included from include/linux/scatterlist.h:9:
   In file included from arch/s390/include/asm/io.h:80:
   include/asm-generic/io.h:464:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __raw_readb(PCI_IOBASE + addr);
                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:477:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/big_endian.h:36:59: note: expanded from macro '__le16_to_cpu'
   #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
                                                             ^
   include/uapi/linux/swab.h:102:54: note: expanded from macro '__swab16'
   #define __swab16(x) (__u16)__builtin_bswap16((__u16)(x))
                                                        ^
   In file included from drivers/nvme/host/multipath.c:6:
   In file included from include/linux/backing-dev.h:15:
   In file included from include/linux/blkdev.h:26:
   In file included from include/linux/scatterlist.h:9:
   In file included from arch/s390/include/asm/io.h:80:
   include/asm-generic/io.h:490:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/big_endian.h:34:59: note: expanded from macro '__le32_to_cpu'
   #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
                                                             ^
   include/uapi/linux/swab.h:115:54: note: expanded from macro '__swab32'
   #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))
                                                        ^
   In file included from drivers/nvme/host/multipath.c:6:
   In file included from include/linux/backing-dev.h:15:
   In file included from include/linux/blkdev.h:26:
   In file included from include/linux/scatterlist.h:9:
   In file included from arch/s390/include/asm/io.h:80:
   include/asm-generic/io.h:501:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writeb(value, PCI_IOBASE + addr);
                               ~~~~~~~~~~ ^
   include/asm-generic/io.h:511:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
   include/asm-generic/io.h:521:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
   include/asm-generic/io.h:609:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           readsb(PCI_IOBASE + addr, buffer, count);
                  ~~~~~~~~~~ ^
   include/asm-generic/io.h:617:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           readsw(PCI_IOBASE + addr, buffer, count);
                  ~~~~~~~~~~ ^
   include/asm-generic/io.h:625:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           readsl(PCI_IOBASE + addr, buffer, count);
                  ~~~~~~~~~~ ^
   include/asm-generic/io.h:634:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           writesb(PCI_IOBASE + addr, buffer, count);
                   ~~~~~~~~~~ ^
   include/asm-generic/io.h:643:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           writesw(PCI_IOBASE + addr, buffer, count);
                   ~~~~~~~~~~ ^
   include/asm-generic/io.h:652:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           writesl(PCI_IOBASE + addr, buffer, count);
                   ~~~~~~~~~~ ^
>> drivers/nvme/host/multipath.c:810:6: warning: variable 'error' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
           if (ana_log_size > max_transfer_size) {
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/nvme/host/multipath.c:832:9: note: uninitialized use occurs here
           return error;
                  ^~~~~
   drivers/nvme/host/multipath.c:810:2: note: remove the 'if' if its condition is always false
           if (ana_log_size > max_transfer_size) {
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/nvme/host/multipath.c:795:11: note: initialize the variable 'error' to silence this warning
           int error;
                    ^
                     = 0
   13 warnings generated.


vim +810 drivers/nvme/host/multipath.c

   790	
   791	int nvme_mpath_init_identify(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
   792	{
   793		size_t max_transfer_size = ctrl->max_hw_sectors << SECTOR_SHIFT;
   794		size_t ana_log_size;
   795		int error;
   796	
   797		/* check if multipath is enabled and we have the capability */
   798		if (!multipath || !ctrl->subsys ||
   799		    !(ctrl->subsys->cmic & NVME_CTRL_CMIC_ANA))
   800			return 0;
   801	
   802		ctrl->anacap = id->anacap;
   803		ctrl->anatt = id->anatt;
   804		ctrl->nanagrpid = le32_to_cpu(id->nanagrpid);
   805		ctrl->anagrpmax = le32_to_cpu(id->anagrpmax);
   806	
   807		ana_log_size = sizeof(struct nvme_ana_rsp_hdr) +
   808			ctrl->nanagrpid * sizeof(struct nvme_ana_group_desc) +
   809			ctrl->max_namespaces * sizeof(__le32);
 > 810		if (ana_log_size > max_transfer_size) {
   811			dev_err(ctrl->device,
   812				"ANA log page size (%zd) larger than MDTS (%zd).\n",
   813				ana_log_size, max_transfer_size);
   814			dev_err(ctrl->device, "disabling ANA support.\n");
   815			goto out_uninit;
   816		}
   817		if (ana_log_size > ctrl->ana_log_size) {
   818			nvme_mpath_stop(ctrl);
   819			kfree(ctrl->ana_log_buf);
   820			ctrl->ana_log_buf = kmalloc(ctrl->ana_log_size, GFP_KERNEL);
   821			if (!ctrl->ana_log_buf)
   822				return -ENOMEM;
   823		}
   824		ctrl->ana_log_size = ana_log_size;
   825		error = nvme_read_ana_log(ctrl);
   826		if (error)
   827			goto out_uninit;
   828		return 0;
   829	
   830	out_uninit:
   831		nvme_mpath_uninit(ctrl);
   832		return error;
   833	}
   834	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 15479 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-nvme/attachments/20210510/a279ee38/attachment-0001.gz>


More information about the Linux-nvme mailing list