Skip to content

Commit

Permalink
ALSA: pcm: Check PCM state at xfern compat ioctl
Browse files Browse the repository at this point in the history
Since snd_pcm_ioctl_xfern_compat() has no PCM state check, it may go
further and hit the sanity check pcm_sanity_check() when the ioctl is
called right after open.  It may eventually spew a kernel warning, as
triggered by syzbot, depending on kconfig.

The lack of PCM state check there was just an oversight.  Although
it's no real crash, the spurious kernel warning is annoying, so let's
add the proper check.

Reported-by: [email protected]
Cc: <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
tiwai committed May 2, 2018
1 parent 76b3421 commit f13876e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sound/core/pcm_compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,8 @@ static int snd_pcm_ioctl_xfern_compat(struct snd_pcm_substream *substream,
return -ENOTTY;
if (substream->stream != dir)
return -EINVAL;
if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN)
return -EBADFD;

if ((ch = substream->runtime->channels) > 128)
return -EINVAL;
Expand Down

0 comments on commit f13876e

Please sign in to comment.