From df0ef271087623439a1e900f323ed2a57204706d Mon Sep 17 00:00:00 2001 From: Pei Xiao Date: Sat, 3 Oct 2026 16:27:53 +0800 Subject: [PATCH] tpm: tpm_nsc: stop using the cleanup callback as dev.release tpm_nsc_remove() is called explicitly from cleanup_nsc() and also runs as the platform device release callback on the final platform_device_put(), so the cleanup executes twice on module exit; the second invocation operates on a chip that has already been freed by the devm cleanup, and the I/O region is released twice. Overwriting the release callback installed by platform_device_alloc() also keeps platform_device_release() from running, leaking the platform object allocation. Leave the default release callback in place; the explicit call in cleanup_nsc() remains the single cleanup point. Cc: stable@vger.kernel.org Fixes: 570302a31149 ("[PATCH] tpm: move nsc driver off pci_dev") Assisted-by: GLM-5.3 Signed-off-by: Pei Xiao Reviewed-by: Jarkko Sakkinen Link: https://lore.kernel.org/r/a6155310e6772f708b47291cc959e02c05b90eb7.1791015549.git.xiaopei01@kylinos.cn Signed-off-by: Jarkko Sakkinen --- drivers/char/tpm/tpm_nsc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/char/tpm/tpm_nsc.c b/drivers/char/tpm/tpm_nsc.c index 46a52dc99b14..bcfa2a1a208a 100644 --- a/drivers/char/tpm/tpm_nsc.c +++ b/drivers/char/tpm/tpm_nsc.c @@ -327,7 +327,6 @@ static int __init init_nsc(void) pdev->num_resources = 0; pdev->dev.driver = &nsc_drv.driver; - pdev->dev.release = tpm_nsc_remove; if ((rc = platform_device_add(pdev)) < 0) goto err_put_dev;