Skip to content

Commit ac6888a

Browse files
Eddie Jamesgroeck
authored andcommitted
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>
1 parent 5e3f89a commit ac6888a

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

drivers/hwmon/occ/common.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,10 +1228,15 @@ EXPORT_SYMBOL_GPL(occ_setup);
12281228

12291229
void occ_shutdown(struct occ *occ)
12301230
{
1231+
mutex_lock(&occ->lock);
1232+
12311233
occ_shutdown_sysfs(occ);
12321234

12331235
if (occ->hwmon)
12341236
hwmon_device_unregister(occ->hwmon);
1237+
occ->hwmon = NULL;
1238+
1239+
mutex_unlock(&occ->lock);
12351240
}
12361241
EXPORT_SYMBOL_GPL(occ_shutdown);
12371242

0 commit comments

Comments
 (0)