diff mbox series

[04/17] wifi: mac80211_hwsim: lock device for manual driver binding

Message ID 20261105-device-trust-core-v1-4-1e536825b4eb@nvidia.com
State New
Headers show
Series driver core: Authorize device trust before driver binding | expand

Commit Message

Leon Romanovsky Nov. 5, 2026, 11:42 a.m. UTC
From: Leon Romanovsky <leonro@nvidia.com>

The documented API contract for device_bind_driver() requires the device
lock. mac80211_hwsim uses it for a newly created class device with no bus,
so no automatic driver-core path can bind the device concurrently and the
missing lock was safe.

Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
 drivers/net/wireless/virtual/mac80211_hwsim_main.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

sashiko-bot@kernel.org Nov. 6, 2026, 11:43 a.m. UTC | #1
> From: Leon Romanovsky <leonro@nvidia.com>
> 
> The documented API contract for device_bind_driver() requires the device
> lock. mac80211_hwsim uses it for a newly created class device with no bus,
> so no automatic driver-core path can bind the device concurrently and the
> missing lock was safe.
> 
> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>

Sashiko has reviewed this patch and found no issues.
diff mbox series

Patch

diff --git a/drivers/net/wireless/virtual/mac80211_hwsim_main.c b/drivers/net/wireless/virtual/mac80211_hwsim_main.c
index e53714b81ec2c..b796da3dd54b3 100644
--- a/drivers/net/wireless/virtual/mac80211_hwsim_main.c
+++ b/drivers/net/wireless/virtual/mac80211_hwsim_main.c
@@ -5769,7 +5769,9 @@  static int mac80211_hwsim_new_radio(struct genl_info *info,
 		goto failed_drvdata;
 	}
 	data->dev->driver = &mac80211_hwsim_driver.driver;
+	device_lock(data->dev);
 	err = device_bind_driver(data->dev);
+	device_unlock(data->dev);
 	if (err != 0) {
 		pr_debug("mac80211_hwsim: device_bind_driver failed (%d)\n",
 		       err);