aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVinod Koul <vinod.koul@linux.intel.com>2012-09-17 02:21:26 -0400
committerTakashi Iwai <tiwai@suse.de>2012-09-17 03:54:50 -0400
commitfb4a9779f1267539292268d7363e17180eb4ee5c (patch)
tree960691ff81a94693b2d0e4ff5db1ba8055bd6f0a
parent4dc040a0b34890d2adc0d63da6e9bfb4eb791b19 (diff)
ALSA: Compress - add codec parameter checks
Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--include/sound/compress_params.h1
-rw-r--r--sound/core/compress_offload.c10
2 files changed, 11 insertions, 0 deletions
diff --git a/include/sound/compress_params.h b/include/sound/compress_params.h
index da4a456de032..602dc6c45d1a 100644
--- a/include/sound/compress_params.h
+++ b/include/sound/compress_params.h
@@ -72,6 +72,7 @@
72#define SND_AUDIOCODEC_IEC61937 ((__u32) 0x0000000B) 72#define SND_AUDIOCODEC_IEC61937 ((__u32) 0x0000000B)
73#define SND_AUDIOCODEC_G723_1 ((__u32) 0x0000000C) 73#define SND_AUDIOCODEC_G723_1 ((__u32) 0x0000000C)
74#define SND_AUDIOCODEC_G729 ((__u32) 0x0000000D) 74#define SND_AUDIOCODEC_G729 ((__u32) 0x0000000D)
75#define SND_AUDIOCODEC_MAX SND_AUDIOCODEC_G729
75 76
76/* 77/*
77 * Profile and modes are listed with bit masks. This allows for a 78 * Profile and modes are listed with bit masks. This allows for a
diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
index bd7f28e89254..c40ae573346d 100644
--- a/sound/core/compress_offload.c
+++ b/sound/core/compress_offload.c
@@ -432,6 +432,16 @@ static int snd_compress_check_input(struct snd_compr_params *params)
432 params->buffer.fragments > SIZE_MAX / params->buffer.fragment_size) 432 params->buffer.fragments > SIZE_MAX / params->buffer.fragment_size)
433 return -EINVAL; 433 return -EINVAL;
434 434
435 /* now codec parameters */
436 if (params->codec.id == 0 || params->codec.id > SND_AUDIOCODEC_MAX)
437 return -EINVAL;
438
439 if (params->codec.ch_in == 0 || params->codec.ch_out == 0)
440 return -EINVAL;
441
442 if (!(params->codec.sample_rate & SNDRV_PCM_RATE_8000_192000))
443 return -EINVAL;
444
435 return 0; 445 return 0;
436} 446}
437 447