diff mbox series

platform/x86/amd/pmf: Initialize and clean up `cb_mutex`

Message ID 20250227170308.435862-1-superm1@kernel.org (mailing list archive)
State Accepted, archived
Headers show
Series platform/x86/amd/pmf: Initialize and clean up `cb_mutex` | expand

Commit Message

Mario Limonciello Feb. 27, 2025, 5:03 p.m. UTC
From: Mario Limonciello <mario.limonciello@amd.com>

`cb_mutex` was introduced in commit 9e0894d07072e ("platform/x86/amd/pmf:
Enable Custom BIOS Inputs for PMF-TA") to prevent conccurrent access for
BIOS inputs. It however isn't initialized and so on use it may lead to
a NULL pointer dereference.

Add code to initialize on probe and clean up on destroy.

Reported-by: Yijun Shen <Yijun.Shen@dell.com>
Cc: Richard Gong <richgong@amd.com>
Fixes: 9e0894d07072e ("platform/x86/amd/pmf: Enable Custom BIOS Inputs for PMF-TA")
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 drivers/platform/x86/amd/pmf/core.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Shen, Yijun Feb. 28, 2025, 4:36 a.m. UTC | #1
Internal Use - Confidential
> -----Original Message-----
> From: Mario Limonciello <superm1@kernel.org>
> Sent: Friday, February 28, 2025 1:03 AM
> To: Limonciello, Mario <mario.limonciello@amd.com>; Shyam-sundar.S-
> k@amd.com; hdegoede@redhat.com; ilpo.jarvinen@linux.intel.com;
> Patil.Reddy@amd.com
> Cc: Shen, Yijun <Yijun_Shen@Dell.com>; Richard Gong
> <richgong@amd.com>; platform-driver-x86@vger.kernel.org
> Subject: [PATCH] platform/x86/amd/pmf: Initialize and clean up `cb_mutex`
>
>
> [EXTERNAL EMAIL]
>
> From: Mario Limonciello <mario.limonciello@amd.com>
>
> `cb_mutex` was introduced in commit 9e0894d07072e
> ("platform/x86/amd/pmf:
> Enable Custom BIOS Inputs for PMF-TA") to prevent conccurrent access for
> BIOS inputs. It however isn't initialized and so on use it may lead to a NULL
> pointer dereference.
>
> Add code to initialize on probe and clean up on destroy.
>
> Reported-by: Yijun Shen <Yijun.Shen@dell.com>
> Cc: Richard Gong <richgong@amd.com>
> Fixes: 9e0894d07072e ("platform/x86/amd/pmf: Enable Custom BIOS Inputs
> for PMF-TA")
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>

Verified the patch on the issued system, the issue is gone.

Tested-By: Yijun Shen <Yijun_Shen@Dell.com>

> ---
>  drivers/platform/x86/amd/pmf/core.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/platform/x86/amd/pmf/core.c
> b/drivers/platform/x86/amd/pmf/core.c
> index 764cc1fe90ae4..a2cb2d5544f5b 100644
> --- a/drivers/platform/x86/amd/pmf/core.c
> +++ b/drivers/platform/x86/amd/pmf/core.c
> @@ -452,6 +452,7 @@ static int amd_pmf_probe(struct platform_device
> *pdev)
>
>       mutex_init(&dev->lock);
>       mutex_init(&dev->update_mutex);
> +     mutex_init(&dev->cb_mutex);
>
>       apmf_acpi_init(dev);
>       platform_set_drvdata(pdev, dev);
> @@ -477,6 +478,7 @@ static void amd_pmf_remove(struct platform_device
> *pdev)
>       amd_pmf_dbgfs_unregister(dev);
>       mutex_destroy(&dev->lock);
>       mutex_destroy(&dev->update_mutex);
> +     mutex_destroy(&dev->cb_mutex);
>       kfree(dev->buf);
>  }
>
> --
> 2.43.0
Shyam Sundar S K March 3, 2025, 6:02 a.m. UTC | #2
On 2/28/2025 10:06, Shen, Yijun wrote:
> 
> Internal Use - Confidential
>> -----Original Message-----
>> From: Mario Limonciello <superm1@kernel.org>
>> Sent: Friday, February 28, 2025 1:03 AM
>> To: Limonciello, Mario <mario.limonciello@amd.com>; Shyam-sundar.S-
>> k@amd.com; hdegoede@redhat.com; ilpo.jarvinen@linux.intel.com;
>> Patil.Reddy@amd.com
>> Cc: Shen, Yijun <Yijun_Shen@Dell.com>; Richard Gong
>> <richgong@amd.com>; platform-driver-x86@vger.kernel.org
>> Subject: [PATCH] platform/x86/amd/pmf: Initialize and clean up `cb_mutex`
>>
>>
>> [EXTERNAL EMAIL]
>>
>> From: Mario Limonciello <mario.limonciello@amd.com>
>>
>> `cb_mutex` was introduced in commit 9e0894d07072e
>> ("platform/x86/amd/pmf:
>> Enable Custom BIOS Inputs for PMF-TA") to prevent conccurrent access for
>> BIOS inputs. It however isn't initialized and so on use it may lead to a NULL
>> pointer dereference.
>>
>> Add code to initialize on probe and clean up on destroy.
>>
>> Reported-by: Yijun Shen <Yijun.Shen@dell.com>
>> Cc: Richard Gong <richgong@amd.com>
>> Fixes: 9e0894d07072e ("platform/x86/amd/pmf: Enable Custom BIOS Inputs
>> for PMF-TA")
>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> 
> Verified the patch on the issued system, the issue is gone.
> 
> Tested-By: Yijun Shen <Yijun_Shen@Dell.com>
> 

Thank you. Looks good.

Acked-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>

>> ---
>>  drivers/platform/x86/amd/pmf/core.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/platform/x86/amd/pmf/core.c
>> b/drivers/platform/x86/amd/pmf/core.c
>> index 764cc1fe90ae4..a2cb2d5544f5b 100644
>> --- a/drivers/platform/x86/amd/pmf/core.c
>> +++ b/drivers/platform/x86/amd/pmf/core.c
>> @@ -452,6 +452,7 @@ static int amd_pmf_probe(struct platform_device
>> *pdev)
>>
>>       mutex_init(&dev->lock);
>>       mutex_init(&dev->update_mutex);
>> +     mutex_init(&dev->cb_mutex);
>>
>>       apmf_acpi_init(dev);
>>       platform_set_drvdata(pdev, dev);
>> @@ -477,6 +478,7 @@ static void amd_pmf_remove(struct platform_device
>> *pdev)
>>       amd_pmf_dbgfs_unregister(dev);
>>       mutex_destroy(&dev->lock);
>>       mutex_destroy(&dev->update_mutex);
>> +     mutex_destroy(&dev->cb_mutex);
>>       kfree(dev->buf);
>>  }
>>
>> --
>> 2.43.0
>
Ilpo Järvinen March 3, 2025, 12:46 p.m. UTC | #3
On Thu, 27 Feb 2025 11:03:06 -0600, Mario Limonciello wrote:

> `cb_mutex` was introduced in commit 9e0894d07072e ("platform/x86/amd/pmf:
> Enable Custom BIOS Inputs for PMF-TA") to prevent conccurrent access for
> BIOS inputs. It however isn't initialized and so on use it may lead to
> a NULL pointer dereference.
> 
> Add code to initialize on probe and clean up on destroy.
> 
> [...]


Thank you for your contribution, it has been applied to my local
review-ilpo-fixes branch. Note it will show up in the public
platform-drivers-x86/review-ilpo-fixes branch only once I've pushed my
local branch there, which might take a while.

The list of commits applied:
[1/1] platform/x86/amd/pmf: Initialize and clean up `cb_mutex`
      commit: 1be4e29e94a6be77de3bc210820b74f40814f17a

--
 i.
diff mbox series

Patch

diff --git a/drivers/platform/x86/amd/pmf/core.c b/drivers/platform/x86/amd/pmf/core.c
index 764cc1fe90ae4..a2cb2d5544f5b 100644
--- a/drivers/platform/x86/amd/pmf/core.c
+++ b/drivers/platform/x86/amd/pmf/core.c
@@ -452,6 +452,7 @@  static int amd_pmf_probe(struct platform_device *pdev)
 
 	mutex_init(&dev->lock);
 	mutex_init(&dev->update_mutex);
+	mutex_init(&dev->cb_mutex);
 
 	apmf_acpi_init(dev);
 	platform_set_drvdata(pdev, dev);
@@ -477,6 +478,7 @@  static void amd_pmf_remove(struct platform_device *pdev)
 	amd_pmf_dbgfs_unregister(dev);
 	mutex_destroy(&dev->lock);
 	mutex_destroy(&dev->update_mutex);
+	mutex_destroy(&dev->cb_mutex);
 	kfree(dev->buf);
 }