[PATCH] cfg80211: Avoid calling WARN_ON() on -ENOMEM in cfg80211_switch_netns()

From: Ivan Abramov
Date: Thu Mar 27 2025 - 21:16:54 EST


It's pointless to call WARN_ON() in case of an allocation failure in
device_rename(), since it only leads to useless splats caused by deliberate
fault injections, so avoid it.

Found by Linux Verification Center (linuxtesting.org) with Syzkaller.

Fixes: 04600794958f ("cfg80211: support sysfs namespaces")
Signed-off-by: Ivan Abramov <i.abramov@xxxxxxxxxxxxxxxxx>
---
net/wireless/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/wireless/core.c b/net/wireless/core.c
index 828e29872633..7c0ca2fd3b45 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -201,7 +201,7 @@ int cfg80211_switch_netns(struct cfg80211_registered_device *rdev,
wiphy_net_set(&rdev->wiphy, net);

err = device_rename(&rdev->wiphy.dev, dev_name(&rdev->wiphy.dev));
- WARN_ON(err);
+ WARN_ON(err && err != -ENOMEM);

nl80211_notify_wiphy(rdev, NL80211_CMD_NEW_WIPHY);

--
2.39.5