From: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>
To: Richard Fitzgerald <rf@opensource.cirrus.com>,
vkoul@kernel.org, yung-chuan.liao@linux.intel.com
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
patches@opensource.cirrus.com
Subject: Re: [PATCH] soundwire: stream: sdw_stream_remove_slave(): Check stream is valid
Date: Thu, 30 Apr 2026 22:01:13 +0200 [thread overview]
Message-ID: <510d048c-288e-469b-9d64-720aeab36398@linux.dev> (raw)
In-Reply-To: <20260430143353.2702714-1-rf@opensource.cirrus.com>
On 4/30/26 16:33, Richard Fitzgerald wrote:
> 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>
LGTM
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>
> ---
> 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);
next prev parent reply other threads:[~2026-04-30 20:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-30 14:33 [PATCH] soundwire: stream: sdw_stream_remove_slave(): Check stream is valid Richard Fitzgerald
2026-04-30 20:01 ` Pierre-Louis Bossart [this message]
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=510d048c-288e-469b-9d64-720aeab36398@linux.dev \
--to=pierre-louis.bossart@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
--cc=rf@opensource.cirrus.com \
--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