Skip to content

Commit cd91fd9

Browse files
plbossarttiwai
authored andcommitted
ALSA: compress_offload: dereference after checking for NULL pointer
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> Acked-by: Vinod Koul <vkoul@kernel.org> Link: https://lore.kernel.org/r/20200902212133.30964-7-pierre-louis.bossart@linux.intel.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 3bcf8ee commit cd91fd9

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎sound/core/compress_offload.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,10 +513,11 @@ EXPORT_SYMBOL(snd_compr_malloc_pages);
513513

514514
int snd_compr_free_pages(struct snd_compr_stream *stream)
515515
{
516-
struct snd_compr_runtime *runtime = stream->runtime;
516+
struct snd_compr_runtime *runtime;
517517

518518
if (snd_BUG_ON(!(stream) || !(stream)->runtime))
519519
return -EINVAL;
520+
runtime = stream->runtime;
520521
if (runtime->dma_area == NULL)
521522
return 0;
522523
if (runtime->dma_buffer_p != &stream->dma_buffer) {

0 commit comments

Comments
 (0)