platform/x86:intel/pmc: Use devm for mutex_init
authorXi Pardee <xi.pardee@linux.intel.com>
Fri, 25 Apr 2025 19:52:31 +0000 (12:52 -0700)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Thu, 8 May 2025 13:03:41 +0000 (16:03 +0300)
Use devm_mutex_init() to avoid accidental resource leak in the
future.

Signed-off-by: Xi Pardee <xi.pardee@linux.intel.com>
Link: https://lore.kernel.org/r/20250425195237.493129-4-xi.pardee@linux.intel.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
drivers/platform/x86/intel/pmc/core.c

index 2028a769cddb3d6dd58a0619f8b98469062f9176..db3fccca06fb76959340117b30a90a1f14c94535 100644 (file)
@@ -1681,7 +1681,6 @@ static void pmc_core_clean_structure(struct platform_device *pdev)
                pmt_telem_unregister_endpoint(pmcdev->punit_ep);
 
        platform_set_drvdata(pdev, NULL);
-       mutex_destroy(&pmcdev->lock);
 }
 
 static int pmc_core_probe(struct platform_device *pdev)
@@ -1726,7 +1725,9 @@ static int pmc_core_probe(struct platform_device *pdev)
        if (!pmcdev->pkgc_res_cnt)
                return -ENOMEM;
 
-       mutex_init(&pmcdev->lock);
+       ret = devm_mutex_init(&pdev->dev, &pmcdev->lock);
+       if (ret)
+               return ret;
 
        if (pmc_dev_info->init)
                ret = pmc_dev_info->init(pmcdev, pmc_dev_info);