From: Takashi Iwai Subject: Re: [PATCH 2/2] ALSA: Compress - add codec parameter checks Date: Mon, 17 Sep 2012 09:59:27 +0200 Message-ID: References: <1347862886-29396-1-git-send-email-vinod.koul@linux.intel.com> <1347862886-29396-2-git-send-email-vinod.koul@linux.intel.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 4668B261643 for ; Mon, 17 Sep 2012 09:59:27 +0200 (CEST) In-Reply-To: <1347862886-29396-2-git-send-email-vinod.koul@linux.intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Vinod Koul Cc: alsa-devel@alsa-project.org, dan.carpenter@oracle.com List-Id: alsa-devel@alsa-project.org At Mon, 17 Sep 2012 11:51:26 +0530, Vinod Koul wrote: > > Signed-off-by: Vinod Koul Applied this one, too. Thanks. Takashi > --- > include/sound/compress_params.h | 1 + > sound/core/compress_offload.c | 10 ++++++++++ > 2 files changed, 11 insertions(+), 0 deletions(-) > > diff --git a/include/sound/compress_params.h b/include/sound/compress_params.h > index da4a456..602dc6c 100644 > --- a/include/sound/compress_params.h > +++ b/include/sound/compress_params.h > @@ -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 > diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c > index bd7f28e..c40ae57 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) > 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; > } > > -- > 1.7.0.4 >