fs/btrfs/volumes.c:1004:34: sparse: sparse: incorrect type in assignment (different address spaces)

From: kernel test robot
Date: Sat Jan 06 2024 - 18:00:14 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 52b1853b080a082ec3749c3a9577f6c71b1d4a90
commit: bb21e30260a672172a26ee1626dc1463215cf18c btrfs: move device->name RCU allocation and assign to btrfs_alloc_device()
date: 1 year, 1 month ago
config: arm-randconfig-r122-20240105 (https://download.01.org/0day-ci/archive/20240107/202401070634.inITDmDk-lkp@xxxxxxxxx/config)
compiler: arm-linux-gnueabi-gcc (GCC) 13.2.0
reproduce: (https://download.01.org/0day-ci/archive/20240107/202401070634.inITDmDk-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202401070634.inITDmDk-lkp@xxxxxxxxx/

sparse warnings: (new ones prefixed by >>)
fs/btrfs/volumes.c:409:31: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct rcu_string *str @@ got struct rcu_string [noderef] __rcu *name @@
fs/btrfs/volumes.c:409:31: sparse: expected struct rcu_string *str
fs/btrfs/volumes.c:409:31: sparse: got struct rcu_string [noderef] __rcu *name
fs/btrfs/volumes.c:617:43: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected char const *device_path @@ got char [noderef] __rcu * @@
fs/btrfs/volumes.c:617:43: sparse: expected char const *device_path
fs/btrfs/volumes.c:617:43: sparse: got char [noderef] __rcu *
fs/btrfs/volumes.c:884:50: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected char const * @@ got char [noderef] __rcu * @@
fs/btrfs/volumes.c:884:50: sparse: expected char const *
fs/btrfs/volumes.c:884:50: sparse: got char [noderef] __rcu *
fs/btrfs/volumes.c:954:39: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct rcu_string *str @@ got struct rcu_string [noderef] __rcu *name @@
fs/btrfs/volumes.c:954:39: sparse: expected struct rcu_string *str
fs/btrfs/volumes.c:954:39: sparse: got struct rcu_string [noderef] __rcu *name
>> fs/btrfs/volumes.c:1004:34: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected char const *dev_path @@ got char [noderef] __rcu * @@
fs/btrfs/volumes.c:1004:34: sparse: expected char const *dev_path
fs/btrfs/volumes.c:1004:34: sparse: got char [noderef] __rcu *
fs/btrfs/volumes.c:2198:49: sparse: sparse: incorrect type in argument 3 (different address spaces) @@ expected char const *device_path @@ got char [noderef] __rcu * @@
fs/btrfs/volumes.c:2198:49: sparse: expected char const *device_path
fs/btrfs/volumes.c:2198:49: sparse: got char [noderef] __rcu *
fs/btrfs/volumes.c:2313:41: sparse: sparse: incorrect type in argument 3 (different address spaces) @@ expected char const *device_path @@ got char [noderef] __rcu * @@
fs/btrfs/volumes.c:2313:41: sparse: expected char const *device_path
fs/btrfs/volumes.c:2313:41: sparse: got char [noderef] __rcu *
fs/btrfs/volumes.c:1446:29: sparse: sparse: self-comparison always evaluates to false

vim +1004 fs/btrfs/volumes.c

980
981 static struct btrfs_fs_devices *clone_fs_devices(struct btrfs_fs_devices *orig)
982 {
983 struct btrfs_fs_devices *fs_devices;
984 struct btrfs_device *device;
985 struct btrfs_device *orig_dev;
986 int ret = 0;
987
988 lockdep_assert_held(&uuid_mutex);
989
990 fs_devices = alloc_fs_devices(orig->fsid, NULL);
991 if (IS_ERR(fs_devices))
992 return fs_devices;
993
994 fs_devices->total_devices = orig->total_devices;
995
996 list_for_each_entry(orig_dev, &orig->devices, dev_list) {
997 const char *dev_path = NULL;
998
999 /*
1000 * This is ok to do without RCU read locked because we hold the
1001 * uuid mutex so nothing we touch in here is going to disappear.
1002 */
1003 if (orig_dev->name)
> 1004 dev_path = orig_dev->name->str;
1005
1006 device = btrfs_alloc_device(NULL, &orig_dev->devid,
1007 orig_dev->uuid, dev_path);
1008 if (IS_ERR(device)) {
1009 ret = PTR_ERR(device);
1010 goto error;
1011 }
1012
1013 if (orig_dev->zone_info) {
1014 struct btrfs_zoned_device_info *zone_info;
1015
1016 zone_info = btrfs_clone_dev_zone_info(orig_dev);
1017 if (!zone_info) {
1018 btrfs_free_device(device);
1019 ret = -ENOMEM;
1020 goto error;
1021 }
1022 device->zone_info = zone_info;
1023 }
1024
1025 list_add(&device->dev_list, &fs_devices->devices);
1026 device->fs_devices = fs_devices;
1027 fs_devices->num_devices++;
1028 }
1029 return fs_devices;
1030 error:
1031 free_fs_devices(fs_devices);
1032 return ERR_PTR(ret);
1033 }
1034

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki