From: Guangshuo Li <lgs201920130244@gmail.com>
To: Cezary Rojewski <cezary.rojewski@intel.com>,
Liam Girdwood <liam.r.girdwood@linux.intel.com>,
Peter Ujfalusi <peter.ujfalusi@linux.intel.com>,
Bard Liao <yung-chuan.liao@linux.intel.com>,
Kai Vehmanen <kai.vehmanen@linux.intel.com>,
Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>,
Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
Takashi Iwai <tiwai@suse.com>,
Thorsten Blum <thorsten.blum@linux.dev>,
Guangshuo Li <lgs201920130244@gmail.com>,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [PATCH] ASoC: Intel: SST: fix platform device leak on probe failure
Date: Mon, 21 Sep 2026 15:38:47 +0800 [thread overview]
Message-ID: <20260921073847.63505-1-lgs201920130244@gmail.com> (raw)
sst_acpi_probe() registers platform devices for the SST platform and
machine drivers using platform_device_register_data(), but does not
unregister them when later probe steps fail.
If machine device registration fails, the already registered SST platform
device is left registered. The same leak happens when
sst_platform_get_resources() or sst_context_init() fails after both
platform devices have been successfully registered.
A registered platform device owns resources allocated by the platform
device core and must be released with platform_device_unregister() so
that the device reference is dropped and platform_device_release() can
free the backing platform_object.
Unregister the created platform devices on all failure paths to restore
the missing cleanup.
The issue was identified by a static analysis tool I developed and
confirmed by manual review.
Fixes: caf94ed8629a ("ASoC: Intel: bytcr_rt5640: fixup DAI codec_name with HID")
Cc: stable@vger.kernel.org
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
sound/soc/intel/atom/sst/sst_acpi.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/sound/soc/intel/atom/sst/sst_acpi.c b/sound/soc/intel/atom/sst/sst_acpi.c
index 73624e1b138a..a1f16083bd3d 100644
--- a/sound/soc/intel/atom/sst/sst_acpi.c
+++ b/sound/soc/intel/atom/sst/sst_acpi.c
@@ -352,7 +352,8 @@ static int sst_acpi_probe(struct platform_device *pdev)
if (IS_ERR(mdev)) {
dev_err(dev, "Failed to create machine device: %s\n",
mach->drv_name);
- return PTR_ERR(mdev);
+ ret = PTR_ERR(mdev);
+ goto err_unregister_plat_dev;
}
/* Fill sst platform data */
@@ -361,15 +362,21 @@ static int sst_acpi_probe(struct platform_device *pdev)
ret = sst_platform_get_resources(ctx);
if (ret)
- return ret;
+ goto err_unregister_mdev;
ret = sst_context_init(ctx);
if (ret < 0)
- return ret;
+ goto err_unregister_mdev;
sst_configure_runtime_pm(ctx);
platform_set_drvdata(pdev, ctx);
return ret;
+
+err_unregister_mdev:
+ platform_device_unregister(mdev);
+err_unregister_plat_dev:
+ platform_device_unregister(plat_dev);
+ return ret;
}
/**
--
2.43.0
next reply other threads:[~2026-09-21 7:38 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-21 7:38 Guangshuo Li [this message]
2026-09-21 9:31 ` Cezary Rojewski
2026-09-22 8:17 ` Guangshuo Li
2026-09-23 8:14 ` Cezary Rojewski
2026-09-24 13:45 ` Guangshuo Li
2026-09-21 15:06 ` krzk
2026-09-22 2:47 ` Guangshuo Li
2026-09-21 15:09 ` krzk
2026-09-21 15:12 ` krzk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260921073847.63505-1-lgs201920130244@gmail.com \
--to=lgs201920130244@gmail.com \
--cc=broonie@kernel.org \
--cc=cezary.rojewski@intel.com \
--cc=kai.vehmanen@linux.intel.com \
--cc=liam.r.girdwood@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=peter.ujfalusi@linux.intel.com \
--cc=pierre-louis.bossart@linux.dev \
--cc=stable@vger.kernel.org \
--cc=thorsten.blum@linux.dev \
--cc=tiwai@suse.com \
--cc=yung-chuan.liao@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®