提交 c07fe5ae 编写于 作者: S Sasha Levin 提交者: Johannes Berg

mac80211_hwsim: correctly register the platform driver

Not registering a platform_driver would make us access garbage
when the platform callbacks under driver_register() kicks in.
Signed-off-by: NSasha Levin <sasha.levin@oracle.com>
Tested-By: NMartin Pitt <martin.pitt@ubuntu.com>
Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
上级 03cd7e4e
...@@ -1723,11 +1723,11 @@ static void mac80211_hwsim_free(void) ...@@ -1723,11 +1723,11 @@ static void mac80211_hwsim_free(void)
class_destroy(hwsim_class); class_destroy(hwsim_class);
} }
static struct platform_driver mac80211_hwsim_driver = {
static struct device_driver mac80211_hwsim_driver = { .driver = {
.name = "mac80211_hwsim", .name = "mac80211_hwsim",
.bus = &platform_bus_type,
.owner = THIS_MODULE, .owner = THIS_MODULE,
},
}; };
static const struct net_device_ops hwsim_netdev_ops = { static const struct net_device_ops hwsim_netdev_ops = {
...@@ -2219,7 +2219,7 @@ static int __init init_mac80211_hwsim(void) ...@@ -2219,7 +2219,7 @@ static int __init init_mac80211_hwsim(void)
spin_lock_init(&hwsim_radio_lock); spin_lock_init(&hwsim_radio_lock);
INIT_LIST_HEAD(&hwsim_radios); INIT_LIST_HEAD(&hwsim_radios);
err = driver_register(&mac80211_hwsim_driver); err = platform_driver_register(&mac80211_hwsim_driver);
if (err) if (err)
return err; return err;
...@@ -2254,7 +2254,7 @@ static int __init init_mac80211_hwsim(void) ...@@ -2254,7 +2254,7 @@ static int __init init_mac80211_hwsim(void)
err = -ENOMEM; err = -ENOMEM;
goto failed_drvdata; goto failed_drvdata;
} }
data->dev->driver = &mac80211_hwsim_driver; data->dev->driver = &mac80211_hwsim_driver.driver;
err = device_bind_driver(data->dev); err = device_bind_driver(data->dev);
if (err != 0) { if (err != 0) {
printk(KERN_DEBUG printk(KERN_DEBUG
...@@ -2564,7 +2564,7 @@ static int __init init_mac80211_hwsim(void) ...@@ -2564,7 +2564,7 @@ static int __init init_mac80211_hwsim(void)
failed: failed:
mac80211_hwsim_free(); mac80211_hwsim_free();
failed_unregister_driver: failed_unregister_driver:
driver_unregister(&mac80211_hwsim_driver); platform_driver_unregister(&mac80211_hwsim_driver);
return err; return err;
} }
module_init(init_mac80211_hwsim); module_init(init_mac80211_hwsim);
...@@ -2577,6 +2577,6 @@ static void __exit exit_mac80211_hwsim(void) ...@@ -2577,6 +2577,6 @@ static void __exit exit_mac80211_hwsim(void)
mac80211_hwsim_free(); mac80211_hwsim_free();
unregister_netdev(hwsim_mon); unregister_netdev(hwsim_mon);
driver_unregister(&mac80211_hwsim_driver); platform_driver_unregister(&mac80211_hwsim_driver);
} }
module_exit(exit_mac80211_hwsim); module_exit(exit_mac80211_hwsim);
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册