All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: alsa-devel@alsa-project.org
Cc: tiwai@suse.de, vkoul@kernel.org, broonie@kernel.org,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Subject: [PATCH 06/18] ALSA: compress_offload: dereference after checking for NULL pointer
Date: Wed,  2 Sep 2020 16:21:21 -0500	[thread overview]
Message-ID: <20200902212133.30964-7-pierre-louis.bossart@linux.intel.com> (raw)
In-Reply-To: <20200902212133.30964-1-pierre-louis.bossart@linux.intel.com>

Fix cppcheck warning and only dereference once the initial checks are
done:

sound/core/compress_offload.c:516:38: warning: Either the condition
'!stream' is redundant or there is possible null pointer dereference:
stream. [nullPointerRedundantCheck]
 struct snd_compr_runtime *runtime = stream->runtime;
                                     ^
sound/core/compress_offload.c:518:17: note: Assuming that condition
'!stream' is not redundant
if (snd_BUG_ON(!(stream) || !(stream)->runtime))
                ^
sound/core/compress_offload.c:516:38: note: Null pointer dereference
 struct snd_compr_runtime *runtime = stream->runtime;
                                     ^

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 sound/core/compress_offload.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
index 0e53f6f31916..e3eb314acb10 100644
--- a/sound/core/compress_offload.c
+++ b/sound/core/compress_offload.c
@@ -513,10 +513,11 @@ EXPORT_SYMBOL(snd_compr_malloc_pages);
 
 int snd_compr_free_pages(struct snd_compr_stream *stream)
 {
-	struct snd_compr_runtime *runtime = stream->runtime;
+	struct snd_compr_runtime *runtime;
 
 	if (snd_BUG_ON(!(stream) || !(stream)->runtime))
 		return -EINVAL;
+	runtime = stream->runtime;
 	if (runtime->dma_area == NULL)
 		return 0;
 	if (runtime->dma_buffer_p != &stream->dma_buffer) {
-- 
2.25.1


  parent reply	other threads:[~2020-09-02 21:26 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-02 21:21 [PATCH 00/18] ALSA: cleanups for sparse/cppcheck warnings Pierre-Louis Bossart
2020-09-02 21:21 ` [PATCH 01/18] ALSA: core: pcm: simplify locking for timers Pierre-Louis Bossart
2020-09-02 21:21 ` [PATCH 02/18] ALSA: core: memalloc: fix fallthrough position Pierre-Louis Bossart
2020-09-02 21:21 ` [PATCH 03/18] ALSA: core: pcm_memory: dereference pointer after NULL checks Pierre-Louis Bossart
2020-09-02 21:21 ` [PATCH 04/18] ALSA: core: timer: remove redundant assignment Pierre-Louis Bossart
2020-09-02 21:21 ` [PATCH 05/18] ALSA: core: timer: clarify operator precedence Pierre-Louis Bossart
2020-09-02 21:21 ` Pierre-Louis Bossart [this message]
2020-09-03  4:47   ` [PATCH 06/18] ALSA: compress_offload: dereference after checking for NULL pointer Vinod Koul
2020-09-02 21:21 ` [PATCH 07/18] ALSA: compress_offload: remove redundant initialization Pierre-Louis Bossart
2020-09-03  4:47   ` Vinod Koul
2020-09-02 21:21 ` [PATCH 08/18] ALSA: core: init: use DECLARE_COMPLETION_ONSTACK() macro Pierre-Louis Bossart
2020-09-02 21:21 ` [PATCH 09/18] ALSA: aoa: i2sbus: " Pierre-Louis Bossart
2020-09-02 21:21 ` [PATCH 10/18] ALSA: hda: auto_parser: remove shadowed variable declaration Pierre-Louis Bossart
2020-09-02 21:21 ` [PATCH 11/18] ALSA: hda: (cosmetic) align function parameters Pierre-Louis Bossart
2020-09-02 21:21 ` [PATCH 12/18] ALSA: usb: scarless_gen2: fix endianness issue Pierre-Louis Bossart
2020-09-02 21:21 ` [PATCH 13/18] ALSA: ac97: (cosmetic) align argument names Pierre-Louis Bossart
2020-09-02 21:21 ` [PATCH 14/18] ALSA: atmel: ac97: clarify operator precedence Pierre-Louis Bossart
2020-09-02 21:21 ` [PATCH 15/18] ALSA: rawmidi: (cosmetic) align function parameters Pierre-Louis Bossart
2020-09-02 21:21 ` [PATCH 16/18] ALSA: vx: vx_core: clarify operator precedence Pierre-Louis Bossart
2020-09-02 21:21 ` [PATCH 17/18] ALSA: vx: vx_pcm: remove redundant assignment Pierre-Louis Bossart
2020-09-02 21:21 ` [PATCH 18/18] " Pierre-Louis Bossart
2020-09-03  7:59 ` [PATCH 00/18] ALSA: cleanups for sparse/cppcheck warnings Takashi Iwai

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=20200902212133.30964-7-pierre-louis.bossart@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=tiwai@suse.de \
    --cc=vkoul@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.