[leon-rdma:rdma-next 57/58] drivers/vfio/pci/mlx5/main.c:599:7: warning: variable 'ret' is used uninitialized whenever 'if' condition is true

From: kernel test robot
Date: Wed Apr 13 2022 - 23:08:16 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/leon/linux-rdma.git rdma-next
head: 11b31c1f85bc8c8add385529aa3f307c3b383a11
commit: 07dcaed2de6ecba1f723f2937a15c4ed3d3bbd4d [57/58] vfio/mlx5: Run the SAVE state command in an async mode
config: arm64-buildonly-randconfig-r005-20220413 (https://download.01.org/0day-ci/archive/20220414/202204141155.DFh8ASSY-lkp@xxxxxxxxx/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 6b7e6ea489f6dd45a9b0da9ac20871560917b9b0)
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 arm64 cross compiling tool for clang build
# apt-get install binutils-aarch64-linux-gnu
# https://git.kernel.org/pub/scm/linux/kernel/git/leon/linux-rdma.git/commit/?id=07dcaed2de6ecba1f723f2937a15c4ed3d3bbd4d
git remote add leon-rdma https://git.kernel.org/pub/scm/linux/kernel/git/leon/linux-rdma.git
git fetch --no-tags leon-rdma rdma-next
git checkout 07dcaed2de6ecba1f723f2937a15c4ed3d3bbd4d
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm64 SHELL=/bin/bash drivers/vfio/pci/mlx5/

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/vfio/pci/mlx5/main.c:599:7: warning: variable 'ret' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (!mvdev->cb_wq)
^~~~~~~~~~~~~
drivers/vfio/pci/mlx5/main.c:623:9: note: uninitialized use occurs here
return ret;
^~~
drivers/vfio/pci/mlx5/main.c:599:3: note: remove the 'if' if its condition is always false
if (!mvdev->cb_wq)
^~~~~~~~~~~~~~~~~~
drivers/vfio/pci/mlx5/main.c:589:9: note: initialize the variable 'ret' to silence this warning
int ret;
^
= 0
1 warning generated.


vim +599 drivers/vfio/pci/mlx5/main.c

584
585 static int mlx5vf_pci_probe(struct pci_dev *pdev,
586 const struct pci_device_id *id)
587 {
588 struct mlx5vf_pci_core_device *mvdev;
589 int ret;
590
591 mvdev = kzalloc(sizeof(*mvdev), GFP_KERNEL);
592 if (!mvdev)
593 return -ENOMEM;
594 vfio_pci_core_init_device(&mvdev->core_device, pdev, &mlx5vf_pci_ops);
595
596 if (pdev->is_virtfn && mlx5vf_cmd_is_migratable(mvdev)) {
597 mvdev->migrate_cap = 1;
598 mvdev->cb_wq = alloc_ordered_workqueue("mlx5vf_wq", 0);
> 599 if (!mvdev->cb_wq)
600 goto out_free;
601 mvdev->core_device.vdev.migration_flags =
602 VFIO_MIGRATION_STOP_COPY |
603 VFIO_MIGRATION_P2P;
604 mutex_init(&mvdev->state_mutex);
605 spin_lock_init(&mvdev->reset_lock);
606 }
607
608 ret = vfio_pci_core_register_device(&mvdev->core_device);
609 if (ret)
610 goto out_free;
611
612 dev_set_drvdata(&pdev->dev, mvdev);
613 return 0;
614
615 out_free:
616 if (mvdev->migrate_cap) {
617 mlx5vf_cmd_remove_migratable(mvdev);
618 if (mvdev->cb_wq)
619 destroy_workqueue(mvdev->cb_wq);
620 }
621 vfio_pci_core_uninit_device(&mvdev->core_device);
622 kfree(mvdev);
623 return ret;
624 }
625

--
0-DAY CI Kernel Test Service
https://01.org/lkp