提交 ac6888ac 编写于 作者: E Eddie James 提交者: Guenter Roeck

hwmon: (occ) Lock mutex in shutdown to prevent race with occ_active

Unbinding the driver or removing the parent device at the same time
as using the OCC active sysfs file can cause the driver to unregister
the hwmon device twice. Prevent this by locking the occ mutex in the
shutdown function.
Signed-off-by: NEddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20220606185455.21126-1-eajames@linux.ibm.comSigned-off-by: NGuenter Roeck <linux@roeck-us.net>
上级 5e3f89ad
...@@ -1228,10 +1228,15 @@ EXPORT_SYMBOL_GPL(occ_setup); ...@@ -1228,10 +1228,15 @@ EXPORT_SYMBOL_GPL(occ_setup);
void occ_shutdown(struct occ *occ) void occ_shutdown(struct occ *occ)
{ {
mutex_lock(&occ->lock);
occ_shutdown_sysfs(occ); occ_shutdown_sysfs(occ);
if (occ->hwmon) if (occ->hwmon)
hwmon_device_unregister(occ->hwmon); hwmon_device_unregister(occ->hwmon);
occ->hwmon = NULL;
mutex_unlock(&occ->lock);
} }
EXPORT_SYMBOL_GPL(occ_shutdown); EXPORT_SYMBOL_GPL(occ_shutdown);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册