Skip to content

Commit

Permalink
ALSA: Compress - add codec parameter checks
Browse files Browse the repository at this point in the history
Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Vinod Koul authored and Takashi Iwai committed Sep 17, 2012
1 parent 4dc040a commit fb4a977
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/sound/compress_params.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
#define SND_AUDIOCODEC_IEC61937 ((__u32) 0x0000000B)
#define SND_AUDIOCODEC_G723_1 ((__u32) 0x0000000C)
#define SND_AUDIOCODEC_G729 ((__u32) 0x0000000D)
#define SND_AUDIOCODEC_MAX SND_AUDIOCODEC_G729

/*
* Profile and modes are listed with bit masks. This allows for a
Expand Down
10 changes: 10 additions & 0 deletions sound/core/compress_offload.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,16 @@ static int snd_compress_check_input(struct snd_compr_params *params)
params->buffer.fragments > SIZE_MAX / params->buffer.fragment_size)
return -EINVAL;

/* now codec parameters */
if (params->codec.id == 0 || params->codec.id > SND_AUDIOCODEC_MAX)
return -EINVAL;

if (params->codec.ch_in == 0 || params->codec.ch_out == 0)
return -EINVAL;

if (!(params->codec.sample_rate & SNDRV_PCM_RATE_8000_192000))
return -EINVAL;

return 0;
}

Expand Down

0 comments on commit fb4a977

Please sign in to comment.