Skip to contentSkip to conversation

mfd: macsmc: Initialize mutex

PATCH Applied Janne Grunau 3 participants 3 messages Dec 31, 2025 – Jan 9

Subsystems (3)
lore
Share & tools
lore

Janne Grunau

author maintainer
#0 lore raw

PATCH v2 1/1 mfd: macsmc: Initialize mutex

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")

---
Changes in v2:
- rewritten commit message
- added missing Cc: stable
- rebased onto v6.19-rc1
- Link to v1: https://lore.kernel.org/r/[email protected]

---
 drivers/mfd/macsmc.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mfd/macsmc.c +1 -0
index e3893e255ce5e4bb4832d80ad1fc002d413a291a..3015e8d36d6e5bfdcea342c7d05a7b34788d7845 100644
@@ -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,

Signature · 1 line
Janne Grunau <[email protected]>
maintainer Reviewed-by on v2 1/1
#1 lore raw
Quoted 8 lines · Janne Grunau

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")
Quoted 7 lines

---
Changes in v2:
- rewritten commit message
- added missing Cc: stable
- rebased onto v6.19-rc1
- Link to v1: https://lore.kernel.org/r/[email protected]
---

Thanks,

Sven

maintainer Applied
#2 lore raw

Re: (subset) [PATCH v2] mfd: macsmc: Initialize mutex

In reply to Janne Grunau
Quoted 6 lines · Janne Grunau

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 [李琼斯]