From: Richard Fitzgerald <rf@opensource.cirrus.com>
To: vkoul@kernel.org, yung-chuan.liao@linux.intel.com,
pierre-louis.bossart@linux.dev
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
patches@opensource.cirrus.com
Subject: [PATCH] soundwire: stream: sdw_stream_remove_slave(): Check stream is valid
Date: Thu, 30 Apr 2026 15:33:53 +0100 [thread overview]
Message-ID: <20260430143353.2702714-1-rf@opensource.cirrus.com> (raw)
In sdw_stream_remove_slave() check that stream is a valid pointer
before passing it to functions that dereference it. Return 0 if the
pointer is invalid.
This is a convenience for callers. They can safely call this function
during cleanup code without needing a pointer validity check duplicated
at every call point.
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
---
drivers/soundwire/stream.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c
index 4ed8fb7663ad..c1ef177a0021 100644
--- a/drivers/soundwire/stream.c
+++ b/drivers/soundwire/stream.c
@@ -2229,11 +2229,15 @@ EXPORT_SYMBOL(sdw_stream_add_slave);
* @slave: SDW Slave instance
* @stream: SoundWire stream
*
- * This removes and frees port_rt and slave_rt from a stream
+ * This removes and frees port_rt and slave_rt from a stream.
+ * If stream is NULL or an ERR_PTR, do nothing and return 0.
*/
int sdw_stream_remove_slave(struct sdw_slave *slave,
struct sdw_stream_runtime *stream)
{
+ if (IS_ERR_OR_NULL(stream))
+ return 0;
+
mutex_lock(&slave->bus->bus_lock);
sdw_slave_port_free(slave, stream);
--
2.47.3
next reply other threads:[~2026-04-30 14:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-30 14:33 Richard Fitzgerald [this message]
2026-04-30 20:01 ` [PATCH] soundwire: stream: sdw_stream_remove_slave(): Check stream is valid Pierre-Louis Bossart
2026-05-03 16:33 ` Vinod Koul
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=20260430143353.2702714-1-rf@opensource.cirrus.com \
--to=rf@opensource.cirrus.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
--cc=pierre-louis.bossart@linux.dev \
--cc=vkoul@kernel.org \
--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