Subject: Re: [PATCH net-next v7 1/4] netdevsim: allow two netdevsim ports to be connected

From: kernel test robot <[email-masked]>
Date: Sun, 28 Jan 2024 06:48:51 +0800

Hi David,

kernel test robot noticed the following build warnings:

[auto build test WARNING on net-next/main]

url:    https://github.com/intel-lab-lkp/linux/commits/David-Wei/netdevsim-allow-two-netdevsim-ports-to-be-connected/20240127-121234
base:   net-next/main
patch link:    https://lore.kernel.org/r/20240127040354.944744-2-dw%40davidwei.uk
patch subject: [PATCH net-next v7 1/4] netdevsim: allow two netdevsim ports to be connected
config: x86_64-randconfig-r122-20240127 (https://download.01.org/0day-ci/archive/20240128/[email-masked]/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240128/[email-masked]/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 <[email-masked]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email-masked]/

sparse warnings: (new ones prefixed by >>)
>> drivers/net/netdevsim/bus.c:349:14: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct netdevsim *peer @@     got struct netdevsim [noderef] __rcu *peer @@
   drivers/net/netdevsim/bus.c:349:14: sparse:     expected struct netdevsim *peer
   drivers/net/netdevsim/bus.c:349:14: sparse:     got struct netdevsim [noderef] __rcu *peer

vim +349 drivers/net/netdevsim/bus.c

   311	
   312	static ssize_t unlink_device_store(const struct bus_type *bus, const char *buf, size_t count)
   313	{
   314		struct netdevsim *nsim, *peer;
   315		unsigned int netnsid, ifidx;
   316		struct net_device *dev;
   317		struct net *ns;
   318		int err;
   319	
   320		err = sscanf(buf, "%u:%u", &netnsid, &ifidx);
   321		if (err != 2) {
   322			pr_err("Format for unlinking a device is \"netnsid:ifidx\" (uint uint).\n");
   323			return -EINVAL;
   324		}
   325	
   326		err = -EINVAL;
   327		rtnl_lock();
   328		ns = get_net_ns_by_id(current->nsproxy->net_ns, netnsid);
   329		if (!ns) {
   330			pr_err("Could not find netns with id: %u\n", netnsid);
   331			goto out_unlock_rtnl;
   332		}
   333	
   334		dev = __dev_get_by_index(ns, ifidx);
   335		if (!dev) {
   336			pr_err("Could not find device with ifindex %u in netnsid %u\n", ifidx, netnsid);
   337			goto out_put_netns;
   338		}
   339	
   340		if (!netdev_is_nsim(dev)) {
   341			pr_err("Device with ifindex %u in netnsid %u is not a netdevsim\n", ifidx, netnsid);
   342			goto out_put_netns;
   343		}
   344	
   345		err = 0;
   346		nsim = netdev_priv(dev);
   347		if (!nsim->peer)
   348			goto out_put_netns;
 > 349		peer = nsim->peer;
   350	
   351		RCU_INIT_POINTER(nsim->peer, NULL);
   352		RCU_INIT_POINTER(peer->peer, NULL);
   353	
   354	out_put_netns:
   355		put_net(ns);
   356	out_unlock_rtnl:
   357		rtnl_unlock();
   358	
   359		return !err ? count : err;
   360	}
   361	static BUS_ATTR_WO(unlink_device);
   362	

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