aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorEddie James <eajames@linux.ibm.com>2022-06-06 13:54:55 -0500
committerGuenter Roeck <linux@roeck-us.net>2022-06-07 05:45:42 -0700
commitac6888ac5a11c0a47d1f1da4b7809c0c595fdc5d (patch)
treead0d649983093866394891e93480940030bfc4e6 /drivers/hwmon
parentdt-bindings: hwmon: ti,tmp401: Drop 'items' from 'ti,n-factor' property (diff)
downloadlinux-dev-ac6888ac5a11c0a47d1f1da4b7809c0c595fdc5d.tar.xz
linux-dev-ac6888ac5a11c0a47d1f1da4b7809c0c595fdc5d.zip
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: Eddie James <eajames@linux.ibm.com> Link: https://lore.kernel.org/r/20220606185455.21126-1-eajames@linux.ibm.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/occ/common.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/hwmon/occ/common.c b/drivers/hwmon/occ/common.c
index d78f4bebc718..ea070b91e5b9 100644
--- a/drivers/hwmon/occ/common.c
+++ b/drivers/hwmon/occ/common.c
@@ -1228,10 +1228,15 @@ EXPORT_SYMBOL_GPL(occ_setup);
void occ_shutdown(struct occ *occ)
{
+ mutex_lock(&occ->lock);
+
occ_shutdown_sysfs(occ);
if (occ->hwmon)
hwmon_device_unregister(occ->hwmon);
+ occ->hwmon = NULL;
+
+ mutex_unlock(&occ->lock);
}
EXPORT_SYMBOL_GPL(occ_shutdown);