OSDN Git Service

ALSA: compress_offload: dereference after checking for NULL pointer
authorPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Wed, 2 Sep 2020 21:21:21 +0000 (16:21 -0500)
committerTakashi Iwai <tiwai@suse.de>
Thu, 3 Sep 2020 07:25:55 +0000 (09:25 +0200)
commitcd91fd9f0af5453e66bda9984916ca67686689cf
treeff550da82f1ff5687a911c32d364d0277df59927
parent3bcf8eeb7d979402d3db96fb58bed456a3c66668
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>
sound/core/compress_offload.c