Skip to contentSkip to conversation

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

PATCH In review Mario Limonciello 4 participants 4 messages Feb 27, 2025 – Mar 3, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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

From: Mario Limonciello <[email protected]>

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.

Cc Richard Gong <[email protected]>
Fixes 9e0894d07072e ("platform/x86/amd/pmf: Enable Custom BIOS Inputs for PMF-TA")
---
 drivers/platform/x86/amd/pmf/core.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/platform/x86/amd/pmf/core.c +2 -0
index 764cc1fe90ae4..a2cb2d5544f5b 100644
@@ -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);
 }
 
Signature · 1 line
2.43.0
Tested-by Yijun Shen on v1 1/1
#1 lore raw

Internal Use - Confidential

Quoted 21 lines

-----Original Message-----
From: Mario Limonciello <[email protected]>
Sent: Friday, February 28, 2025 1:03 AM
To: Limonciello, Mario <[email protected]>; Shyam-sundar.S- [email protected]; [email protected]; [email protected]; [email protected]
Cc: Shen, Yijun <[email protected]>; Richard Gong <[email protected]>; [email protected]
Subject: [PATCH] platform/x86/amd/pmf: Initialize and clean up cb_mutex

[EXTERNAL EMAIL]

From: Mario Limonciello <[email protected]>

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.

Quoted 7 lines

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

Cc Richard Gong <[email protected]>
Fixes 9e0894d07072e ("platform/x86/amd/pmf: Enable Custom BIOS Inputs

for PMF-TA")

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

Quoted 29 lines
---
 drivers/platform/x86/amd/pmf/core.c | 2 +-+-
 1 file changed, 2 insertions(+-)
drivers/platform/x86/amd/pmf/core.c +1 -1
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

maintainer Acked-by
#2 lore raw
Quoted 31 lines · Yijun

Internal Use - Confidential

Quoted 21 lines

-----Original Message-----
From: Mario Limonciello <[email protected]>
Sent: Friday, February 28, 2025 1:03 AM
To: Limonciello, Mario <[email protected]>; Shyam-sundar.S- [email protected]; [email protected]; [email protected]; [email protected]
Cc: Shen, Yijun <[email protected]>; Richard Gong <[email protected]>; [email protected]
Subject: [PATCH] platform/x86/amd/pmf: Initialize and clean up cb_mutex

[EXTERNAL EMAIL]

From: Mario Limonciello <[email protected]>

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.

Quoted 7 lines

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

Cc Richard Gong <[email protected]>
Fixes 9e0894d07072e ("platform/x86/amd/pmf: Enable Custom BIOS Inputs

for PMF-TA")

Quoted 4 lines

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

Thank you. Looks good.

Quoted 30 lines
Quoted 29 lines
---
 drivers/platform/x86/amd/pmf/core.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/platform/x86/amd/pmf/core.c +1 -0
index 764cc1fe90ae4..a2cb2d5544f5b 100644
@@ -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);
drivers/platform/x86/amd/pmf/core.c +1 -1
@@ -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

maintainer
#3 lore raw
In reply to Mario Limonciello
Quoted 8 lines · Mario Limonciello

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.