Skip to content

Commit 75deea3

Browse files
tiwaiLee Jones
authored and
Lee Jones
committed
ALSA: info: Drop WARN_ON() from buffer NULL sanity check
commit 60379ba08532eca861e933b389526a4dc89e0c42 upstream. snd_info_get_line() has a sanity check of NULL buffer -- both buffer itself being NULL and buffer->buffer being NULL. Basically both checks are valid and necessary, but the problem is that it's with snd_BUG_ON() macro that triggers WARN_ON(). The latter condition (NULL buffer->buffer) can be met arbitrarily by user since the buffer is allocated at the first write, so it means that user can trigger WARN_ON() at will. This patch addresses it by simply moving buffer->buffer NULL check out of snd_BUG_ON() so that spurious WARNING is no longer triggered. Reported-by: [email protected] Cc: <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Lee Jones <[email protected]> Change-Id: Ib2982f1bfd375ce7ac022071607de4e6c498acc1
1 parent eeac801 commit 75deea3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

sound/core/info.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,9 @@ int snd_info_get_line(struct snd_info_buffer *buffer, char *line, int len)
696696
{
697697
int c = -1;
698698

699-
if (snd_BUG_ON(!buffer || !buffer->buffer))
699+
if (snd_BUG_ON(!buffer))
700+
return 1;
701+
if (!buffer->buffer)
700702
return 1;
701703
if (len <= 0 || buffer->stop || buffer->error)
702704
return 1;

0 commit comments

Comments
 (0)