From: Vinod Koul <vkoul@kernel.org>
To: trix@redhat.com
Cc: yung-chuan.liao@linux.intel.com,
pierre-louis.bossart@linux.intel.com, sanyog.r.kale@intel.com,
natechancellor@gmail.com, ndesaulniers@google.com,
guennadi.liakhovetski@linux.intel.com,
kai.vehmanen@linux.intel.com, alsa-devel@alsa-project.org,
linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com
Subject: Re: [PATCH] soundwire: stream: fix an invalid free
Date: Mon, 7 Sep 2020 19:44:02 +0530 [thread overview]
Message-ID: <20200907141402.GC2639@vkoul-mobl> (raw)
In-Reply-To: <20200905192613.420-1-trix@redhat.com>
Hello Tom,
On 05-09-20, 12:26, trix@redhat.com wrote:
> From: Tom Rix <trix@redhat.com>
>
> clang static analyzer reports this problem
>
> stream.c:872:2: warning: Argument to kfree() is a constant
> address (18446744073709551092), which is not memory
> allocated by malloc()
> kfree(stream);
> ^~~~~~~~~~~~~
>
> In sdw_shutdown_stream() the stream to free is set by
> a call to snd_soc_dai_get_sdw_stream(). The problem block
> is the check if the call was successful.
>
> if (!sdw_stream) {
> dev_err(rtd->dev, "no stream found...
> return;
> }
>
> When snd_soc_dai_get_sdw_stream() fails, it does not
> always return null, sometimes it returns -ENOTSUPP.
>
> So also check for error codes.
> Fixes: 4550569bd779 ("soundwire: stream: add helper to startup/shutdown streams")
> Signed-off-by: Tom Rix <trix@redhat.com>
> ---
> drivers/soundwire/stream.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c
> index 6e36deb505b1..950231d593c2 100644
> --- a/drivers/soundwire/stream.c
> +++ b/drivers/soundwire/stream.c
> @@ -1913,7 +1913,7 @@ void sdw_shutdown_stream(void *sdw_substream)
>
> sdw_stream = snd_soc_dai_get_sdw_stream(dai, substream->stream);
>
> - if (!sdw_stream) {
> + if (IS_ERR_OR_NULL(sdw_stream)) {
Thanks for the patch. Please see commit 3471d2a192ba ("soundwire:
stream: fix NULL/IS_ERR confusion") in soundwire-next. This has already
been updated to IS_ERR() and Bard has already sent patches for
snd_soc_dai_get_sdw_stream() to return proper values.
So I you can rerun this on next, you should see this fixed.
--
~Vinod
next prev parent reply other threads:[~2020-09-07 17:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-05 19:26 [PATCH] soundwire: stream: fix an invalid free trix
2020-09-07 14:14 ` Vinod Koul [this message]
2020-09-07 14:25 ` Tom Rix
2020-09-07 16:55 ` 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=20200907141402.GC2639@vkoul-mobl \
--to=vkoul@kernel.org \
--cc=alsa-devel@alsa-project.org \
--cc=clang-built-linux@googlegroups.com \
--cc=guennadi.liakhovetski@linux.intel.com \
--cc=kai.vehmanen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=natechancellor@gmail.com \
--cc=ndesaulniers@google.com \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=sanyog.r.kale@intel.com \
--cc=trix@redhat.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;
as well as URLs for NNTP newsgroup(s).