[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:36:12 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: x86_64-randconfig-a015-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 x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-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=x86_64 

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 >>):

>> 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
   1 warning 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: 30955 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-nvme/attachments/20210510/869fcc28/attachment-0001.gz>


More information about the Linux-nvme mailing list