]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
mfd: macsmc: Initialize mutex
authorJanne Grunau <j@jannau.net>
Wed, 31 Dec 2025 09:42:12 +0000 (10:42 +0100)
committerLee Jones <lee@kernel.org>
Thu, 22 Jan 2026 14:23:20 +0000 (14:23 +0000)
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.

Cc: stable@vger.kernel.org
Fixes: e038d985c9823 ("mfd: Add Apple Silicon System Management Controller")
Signed-off-by: Janne Grunau <j@jannau.net>
Reviewed-by: Sven Peter <sven@kernel.org>
Reviewed-by: Neal Gompa <neal@gompa.dev>
Link: https://patch.msgid.link/20251231-macsmc-mutex_init-v2-1-5818c9dc9b29@jannau.net
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/mfd/macsmc.c

index 85410f3576030d0e390a260c789254c70ee83b91..1b7e7b3e785f277b4c0630cd8f69bd855f1723eb 100644 (file)
@@ -416,6 +416,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))