Skip to content

Commit e0c4052

Browse files
committed
platform/x86/amd/pmf: Ensure mutexes are initialized before use
As soon as the first handler or sysfs file is registered the mutex may get used. Move the initialization to before any handler registration / sysfs file creation. Likewise move the destruction of the mutex to after all the de-initialization is done. Fixes: da5ce22 ("platform/x86/amd/pmf: Add support for PMF core layer") Signed-off-by: Hans de Goede <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent f21bf62 commit e0c4052

File tree

1 file changed

+5
-4
lines changed
  • drivers/platform/x86/amd/pmf

1 file changed

+5
-4
lines changed

drivers/platform/x86/amd/pmf/core.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,9 @@ static int amd_pmf_probe(struct platform_device *pdev)
385385
if (!dev->regbase)
386386
return -ENOMEM;
387387

388+
mutex_init(&dev->lock);
389+
mutex_init(&dev->update_mutex);
390+
388391
apmf_acpi_init(dev);
389392
platform_set_drvdata(pdev, dev);
390393
amd_pmf_init_features(dev);
@@ -394,8 +397,6 @@ static int amd_pmf_probe(struct platform_device *pdev)
394397
dev->pwr_src_notifier.notifier_call = amd_pmf_pwr_src_notify_call;
395398
power_supply_reg_notifier(&dev->pwr_src_notifier);
396399

397-
mutex_init(&dev->lock);
398-
mutex_init(&dev->update_mutex);
399400
dev_info(dev->dev, "registered PMF device successfully\n");
400401

401402
return 0;
@@ -406,11 +407,11 @@ static int amd_pmf_remove(struct platform_device *pdev)
406407
struct amd_pmf_dev *dev = platform_get_drvdata(pdev);
407408

408409
power_supply_unreg_notifier(&dev->pwr_src_notifier);
409-
mutex_destroy(&dev->lock);
410-
mutex_destroy(&dev->update_mutex);
411410
amd_pmf_deinit_features(dev);
412411
apmf_acpi_deinit(dev);
413412
amd_pmf_dbgfs_unregister(dev);
413+
mutex_destroy(&dev->lock);
414+
mutex_destroy(&dev->update_mutex);
414415
kfree(dev->buf);
415416
return 0;
416417
}

0 commit comments

Comments
 (0)