[PATCH v2] mfd: macsmc: Initialize mutex

Janne Grunau posted 1 patch 1 month, 1 week ago
drivers/mfd/macsmc.c | 1 +
1 file changed, 1 insertion(+)
[PATCH v2] mfd: macsmc: Initialize mutex
Posted by Janne Grunau 1 month, 1 week ago
Initialize struct apple_smc's mutex in apple_smc_probe(). Using the
mutex uninitialized surprisingly resulted only in occasional NULL
pointer dereferences in apple_smc_read() calls from the probe()
functions of sub devices.

Fixes: e038d985c9823 ("mfd: Add Apple Silicon System Management Controller")
Cc: stable@vger.kernel.org
Signed-off-by: Janne Grunau <j@jannau.net>
---
Changes in v2:
- rewritten commit message
- added missing Cc: stable
- rebased onto v6.19-rc1
- Link to v1: https://lore.kernel.org/r/20250925-macsmc-mutex_init-v1-1-416e9e644735@jannau.net
---
 drivers/mfd/macsmc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mfd/macsmc.c b/drivers/mfd/macsmc.c
index e3893e255ce5e4bb4832d80ad1fc002d413a291a..3015e8d36d6e5bfdcea342c7d05a7b34788d7845 100644
--- a/drivers/mfd/macsmc.c
+++ b/drivers/mfd/macsmc.c
@@ -413,6 +413,7 @@ static int apple_smc_probe(struct platform_device *pdev)
 	if (!smc)
 		return -ENOMEM;
 
+	mutex_init(&smc->mutex);
 	smc->dev = &pdev->dev;
 	smc->sram_base = devm_platform_get_and_ioremap_resource(pdev, 1, &smc->sram);
 	if (IS_ERR(smc->sram_base))

---
base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
change-id: 20250925-macsmc-mutex_init-80d7cb2aacfa

Best regards,
-- 
Janne Grunau <j@jannau.net>
Re: (subset) [PATCH v2] mfd: macsmc: Initialize mutex
Posted by Lee Jones 1 month ago
On Wed, 31 Dec 2025 10:42:12 +0100, Janne Grunau wrote:
> Initialize struct apple_smc's mutex in apple_smc_probe(). Using the
> mutex uninitialized surprisingly resulted only in occasional NULL
> pointer dereferences in apple_smc_read() calls from the probe()
> functions of sub devices.
> 
> 

Applied, thanks!

[1/1] mfd: macsmc: Initialize mutex
      commit: 9f7cd8015f588755ada102d400c58ed1ca28a63d

--
Lee Jones [李琼斯]

Re: [PATCH v2] mfd: macsmc: Initialize mutex
Posted by Sven Peter 1 month ago
On 31.12.25 10:42, Janne Grunau wrote:
> Initialize struct apple_smc's mutex in apple_smc_probe(). Using the
> mutex uninitialized surprisingly resulted only in occasional NULL
> pointer dereferences in apple_smc_read() calls from the probe()
> functions of sub devices.
> 
> Fixes: e038d985c9823 ("mfd: Add Apple Silicon System Management Controller")
> Cc: stable@vger.kernel.org
> Signed-off-by: Janne Grunau <j@jannau.net>
> ---
> Changes in v2:
> - rewritten commit message
> - added missing Cc: stable
> - rebased onto v6.19-rc1
> - Link to v1: https://lore.kernel.org/r/20250925-macsmc-mutex_init-v1-1-416e9e644735@jannau.net
> ---

Reviewed-by: Sven Peter <sven@kernel.org>


Thanks,

Sven