[lvc-project] [PATCH v2 1/3] cfg80211: Restore initial state on failed device_rename() in cfg80211_switch_netns()

Kuniyuki Iwashima kuniyu at amazon.com
Wed Apr 23 21:16:40 MSK 2025


From: Johannes Berg <johannes at sipsolutions.net>
Date: Wed, 23 Apr 2025 17:44:45 +0200
> On Mon, 2025-04-07 at 15:53 +0300, Ivan Abramov wrote:
> > Currently, the return value of device_rename() is not acted upon.
> > 
> > To avoid an inconsistent state in case of failure, roll back the changes
> > made before the device_rename() call.
> 
> This kind of seems complicated for something that ought to not happen
> ...
> 
> And also (+netdev), what do we do in case this is called from
> cfg80211_pernet_exit() - leak the whole network namespace because we
> couldn't allocate memory for the name? That seems counterproductive.

default_device_exit_net() does BUG() in such a case, it doens't
assume -ENOMEM as we are freeing memory in the netns dismantle.


static void __net_exit default_device_exit_net(struct net *net)
{
...
	for_each_netdev_safe(net, dev, aux) {
...
		err = dev_change_net_namespace(dev, &init_net, fb_name);
		if (err) {
			pr_emerg("%s: failed to move %s to init_net: %d\n",
				 __func__, dev->name, err);
			BUG();
		}
	}
}



More information about the lvc-project mailing list