[cxl-cxl:pending 31/38] drivers/cxl/pmem.c:66:6: warning: variable 'nvdimm' is used uninitialized whenever 'if' condition is true

From: kernel test robot
Date: Sat Aug 14 2021 - 02:59:38 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl.git pending
head: fa809cc6feedcd2575b63def7135dfaf066266bb
commit: fc6fd550b9f1ada1bdb5e12f83e3794e81a2eb42 [31/38] cxl/mbox: Add exclusive kernel command support
config: x86_64-randconfig-a015-20210814 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 1f7b25ea76a925aca690da28de9d78db7ca99d0c)
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
# https://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl.git/commit/?id=fc6fd550b9f1ada1bdb5e12f83e3794e81a2eb42
git remote add cxl-cxl https://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl.git
git fetch --no-tags cxl-cxl pending
git checkout fc6fd550b9f1ada1bdb5e12f83e3794e81a2eb42
# 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/cxl/pmem.c:66:6: warning: variable 'nvdimm' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (!cxl_nvb->nvdimm_bus)
^~~~~~~~~~~~~~~~~~~~
drivers/cxl/pmem.c:80:7: note: uninitialized use occurs here
if (!nvdimm && rc == 0)
^~~~~~
drivers/cxl/pmem.c:66:2: note: remove the 'if' if its condition is always false
if (!cxl_nvb->nvdimm_bus)
^~~~~~~~~~~~~~~~~~~~~~~~~
drivers/cxl/pmem.c:58:23: note: initialize the variable 'nvdimm' to silence this warning
struct nvdimm *nvdimm;
^
= NULL
1 warning generated.


vim +66 drivers/cxl/pmem.c

21083f51521fb0 Dan Williams 2021-06-15 50
21083f51521fb0 Dan Williams 2021-06-15 51 static int cxl_nvdimm_probe(struct device *dev)
21083f51521fb0 Dan Williams 2021-06-15 52 {
21083f51521fb0 Dan Williams 2021-06-15 53 struct cxl_nvdimm *cxl_nvd = to_cxl_nvdimm(dev);
fc6fd550b9f1ad Dan Williams 2021-06-17 54 struct cxl_memdev *cxlmd = cxl_nvd->cxlmd;
fc6fd550b9f1ad Dan Williams 2021-06-17 55 struct cxl_mem *cxlm = cxlmd->cxlm;
21083f51521fb0 Dan Williams 2021-06-15 56 struct cxl_nvdimm_bridge *cxl_nvb;
21083f51521fb0 Dan Williams 2021-06-15 57 unsigned long flags = 0;
21083f51521fb0 Dan Williams 2021-06-15 58 struct nvdimm *nvdimm;
21083f51521fb0 Dan Williams 2021-06-15 59 int rc = -ENXIO;
21083f51521fb0 Dan Williams 2021-06-15 60
21083f51521fb0 Dan Williams 2021-06-15 61 cxl_nvb = cxl_find_nvdimm_bridge();
21083f51521fb0 Dan Williams 2021-06-15 62 if (!cxl_nvb)
21083f51521fb0 Dan Williams 2021-06-15 63 return -ENXIO;
21083f51521fb0 Dan Williams 2021-06-15 64
21083f51521fb0 Dan Williams 2021-06-15 65 device_lock(&cxl_nvb->dev);
21083f51521fb0 Dan Williams 2021-06-15 @66 if (!cxl_nvb->nvdimm_bus)
21083f51521fb0 Dan Williams 2021-06-15 67 goto out;
21083f51521fb0 Dan Williams 2021-06-15 68
fc6fd550b9f1ad Dan Williams 2021-06-17 69 set_exclusive_cxl_commands(cxlm, exclusive_cmds);
fc6fd550b9f1ad Dan Williams 2021-06-17 70
21083f51521fb0 Dan Williams 2021-06-15 71 set_bit(NDD_LABELING, &flags);
21083f51521fb0 Dan Williams 2021-06-15 72 nvdimm = nvdimm_create(cxl_nvb->nvdimm_bus, cxl_nvd, NULL, flags, 0, 0,
21083f51521fb0 Dan Williams 2021-06-15 73 NULL);
fc6fd550b9f1ad Dan Williams 2021-06-17 74 dev_set_drvdata(dev, nvdimm);
fc6fd550b9f1ad Dan Williams 2021-06-17 75 rc = devm_add_action_or_reset(dev, unregister_nvdimm, cxl_nvd);
21083f51521fb0 Dan Williams 2021-06-15 76 out:
21083f51521fb0 Dan Williams 2021-06-15 77 device_unlock(&cxl_nvb->dev);
21083f51521fb0 Dan Williams 2021-06-15 78 put_device(&cxl_nvb->dev);
21083f51521fb0 Dan Williams 2021-06-15 79
fc6fd550b9f1ad Dan Williams 2021-06-17 80 if (!nvdimm && rc == 0)
fc6fd550b9f1ad Dan Williams 2021-06-17 81 rc = -ENOMEM;
fc6fd550b9f1ad Dan Williams 2021-06-17 82
21083f51521fb0 Dan Williams 2021-06-15 83 return rc;
21083f51521fb0 Dan Williams 2021-06-15 84 }
21083f51521fb0 Dan Williams 2021-06-15 85

:::::: The code at line 66 was first introduced by commit
:::::: 21083f51521fb0f60dbac591f175c3ed48435af4 cxl/pmem: Register 'pmem' / cxl_nvdimm devices

:::::: TO: Dan Williams <dan.j.williams@xxxxxxxxx>
:::::: CC: Dan Williams <dan.j.williams@xxxxxxxxx>

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

Attachment: .config.gz
Description: application/gzip