aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/fsl
diff options
context:
space:
mode:
authorNicolin Chen <nicoleotsuka@gmail.com>2014-08-04 00:19:49 -0400
committerMark Brown <broonie@linaro.org>2014-08-04 10:48:41 -0400
commit4e13eb722153a5ad66edd80bc26c3028d96a7b93 (patch)
tree4d8180c5b4a13de2aa951c3f2024062ec4a446db /sound/soc/fsl
parent6ccf62c7bea561cca7ffbd50839f883327080800 (diff)
ASoC: fsl_asrc: Don't access members of config before checking it
sound/soc/fsl/fsl_asrc.c:250 fsl_asrc_config_pair() warn: variable dereferenced before check 'config' (see line 243) git remote add next git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git git remote update next git checkout 3117bb3109dc223e186302f5dc8ce9ed04adca90 vim +/config +250 sound/soc/fsl/fsl_asrc.c 237 */ 238 static int fsl_asrc_config_pair(struct fsl_asrc_pair *pair) 239 { 240 struct asrc_config *config = pair->config; 241 struct fsl_asrc *asrc_priv = pair->asrc_priv; 242 enum asrc_pair_index index = pair->index; @243 u32 inrate = config->input_sample_rate, indiv; 244 u32 outrate = config->output_sample_rate, outdiv; 245 bool ideal = config->inclk == INCLK_NONE; 246 u32 clk_index[2], div[2]; 247 int in, out, channels; 248 struct clk *clk; 249 @250 if (!config) { 251 pair_err("invalid pair config\n"); 252 return -EINVAL; 253 } Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Nicolin Chen <nicoleotsuka@gmail.com> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound/soc/fsl')
-rw-r--r--sound/soc/fsl/fsl_asrc.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c
index 424b23c38d9a..822110420b71 100644
--- a/sound/soc/fsl/fsl_asrc.c
+++ b/sound/soc/fsl/fsl_asrc.c
@@ -240,12 +240,11 @@ static int fsl_asrc_config_pair(struct fsl_asrc_pair *pair)
240 struct asrc_config *config = pair->config; 240 struct asrc_config *config = pair->config;
241 struct fsl_asrc *asrc_priv = pair->asrc_priv; 241 struct fsl_asrc *asrc_priv = pair->asrc_priv;
242 enum asrc_pair_index index = pair->index; 242 enum asrc_pair_index index = pair->index;
243 u32 inrate = config->input_sample_rate, indiv; 243 u32 inrate, outrate, indiv, outdiv;
244 u32 outrate = config->output_sample_rate, outdiv;
245 bool ideal = config->inclk == INCLK_NONE;
246 u32 clk_index[2], div[2]; 244 u32 clk_index[2], div[2];
247 int in, out, channels; 245 int in, out, channels;
248 struct clk *clk; 246 struct clk *clk;
247 bool ideal;
249 248
250 if (!config) { 249 if (!config) {
251 pair_err("invalid pair config\n"); 250 pair_err("invalid pair config\n");
@@ -264,6 +263,10 @@ static int fsl_asrc_config_pair(struct fsl_asrc_pair *pair)
264 return -EINVAL; 263 return -EINVAL;
265 } 264 }
266 265
266 inrate = config->input_sample_rate;
267 outrate = config->output_sample_rate;
268 ideal = config->inclk == INCLK_NONE;
269
267 /* Validate input and output sample rates */ 270 /* Validate input and output sample rates */
268 for (in = 0; in < ARRAY_SIZE(supported_input_rate); in++) 271 for (in = 0; in < ARRAY_SIZE(supported_input_rate); in++)
269 if (inrate == supported_input_rate[in]) 272 if (inrate == supported_input_rate[in])