alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Johan Hovold <johan+linaro@kernel.org>
To: Mark Brown <broonie@kernel.org>
Cc: Liam Girdwood <lgirdwood@gmail.com>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
	alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
	Johan Hovold <johan+linaro@kernel.org>,
	stable@vger.kernel.org
Subject: [PATCH 6/7] ASoC: codecs: wcd938x-sdw: fix use after free on driver unbind
Date: Tue,  3 Oct 2023 17:55:57 +0200	[thread overview]
Message-ID: <20231003155558.27079-7-johan+linaro@kernel.org> (raw)
In-Reply-To: <20231003155558.27079-1-johan+linaro@kernel.org>

Make sure to deregister the component when the driver is being unbound
and before the underlying device-managed resources are freed.

Fixes: 16572522aece ("ASoC: codecs: wcd938x-sdw: add SoundWire driver")
Cc: stable@vger.kernel.org      # 5.14
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
---
 sound/soc/codecs/wcd938x-sdw.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/sound/soc/codecs/wcd938x-sdw.c b/sound/soc/codecs/wcd938x-sdw.c
index 6951120057e5..1baea04480e2 100644
--- a/sound/soc/codecs/wcd938x-sdw.c
+++ b/sound/soc/codecs/wcd938x-sdw.c
@@ -1281,6 +1281,15 @@ static int wcd9380_probe(struct sdw_slave *pdev,
 	return component_add(dev, &wcd938x_sdw_component_ops);
 }
 
+static int wcd9380_remove(struct sdw_slave *pdev)
+{
+	struct device *dev = &pdev->dev;
+
+	component_del(dev, &wcd938x_sdw_component_ops);
+
+	return 0;
+}
+
 static const struct sdw_device_id wcd9380_slave_id[] = {
 	SDW_SLAVE_ENTRY(0x0217, 0x10d, 0),
 	{},
@@ -1320,6 +1329,7 @@ static const struct dev_pm_ops wcd938x_sdw_pm_ops = {
 
 static struct sdw_driver wcd9380_codec_driver = {
 	.probe	= wcd9380_probe,
+	.remove	= wcd9380_remove,
 	.ops = &wcd9380_slave_ops,
 	.id_table = wcd9380_slave_id,
 	.driver = {
-- 
2.41.0


  parent reply	other threads:[~2023-10-03 16:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-03 15:55 [PATCH 0/7] ASoC: codecs: wcd938x: fix probe and bind error handling Johan Hovold
2023-10-03 15:55 ` [PATCH 1/7] ASoC: codecs: wcd938x: drop bogus " Johan Hovold
2023-10-03 15:55 ` [PATCH 2/7] ASoC: codecs: wcd938x: fix unbind tear down order Johan Hovold
2023-10-03 15:55 ` [PATCH 3/7] ASoC: codecs: wcd938x: fix resource leaks on bind errors Johan Hovold
2023-10-03 15:55 ` [PATCH 4/7] ASoC: codecs: wcd938x: fix regulator leaks on probe errors Johan Hovold
2023-10-03 15:55 ` [PATCH 5/7] ASoC: codecs: wcd938x: fix runtime PM imbalance on remove Johan Hovold
2023-10-03 15:55 ` Johan Hovold [this message]
2023-10-03 15:55 ` [PATCH 7/7] ASoC: codecs: wcd938x-sdw: fix runtime PM imbalance on probe errors Johan Hovold
2023-10-09 18:36 ` [PATCH 0/7] ASoC: codecs: wcd938x: fix probe and bind error handling Mark Brown

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=20231003155558.27079-7-johan+linaro@kernel.org \
    --to=johan+linaro@kernel.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=srinivas.kandagatla@linaro.org \
    --cc=stable@vger.kernel.org \
    --cc=tiwai@suse.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;
as well as URLs for NNTP newsgroup(s).