* [PATCH 0/2] ASoC: fsl_asrc: Fix two dereferenced variable before check
@ 2014-08-04 4:19 Nicolin Chen
2014-08-04 4:19 ` [PATCH 1/2] ASoC: fsl_sarc_dma: Check pair before using it Nicolin Chen
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Nicolin Chen @ 2014-08-04 4:19 UTC (permalink / raw)
To: broonie; +Cc: alsa-devel, linuxppc-dev, linux-kernel, timur
These two patches fixes two warning of dereferenced variable reported by
Dan Carpenter <dan.carpenter@oracle.com>
Nicolin Chen (2):
ASoC: fsl_sarc_dma: Check pair before using it
ASoC: fsl_asrc: Don't access members of config before checking it
sound/soc/fsl/fsl_asrc.c | 9 ++++++---
sound/soc/fsl/fsl_asrc_dma.c | 9 +++++++--
2 files changed, 13 insertions(+), 5 deletions(-)
--
1.8.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] ASoC: fsl_sarc_dma: Check pair before using it
2014-08-04 4:19 [PATCH 0/2] ASoC: fsl_asrc: Fix two dereferenced variable before check Nicolin Chen
@ 2014-08-04 4:19 ` Nicolin Chen
2014-08-04 4:19 ` [PATCH 2/2] ASoC: fsl_asrc: Don't access members of config before checking it Nicolin Chen
2014-08-04 14:48 ` [PATCH 0/2] ASoC: fsl_asrc: Fix two dereferenced variable before check Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Nicolin Chen @ 2014-08-04 4:19 UTC (permalink / raw)
To: broonie; +Cc: alsa-devel, linuxppc-dev, linux-kernel, timur
The patch 3117bb3109dc: "ASoC: fsl_asrc: Add ASRC ASoC CPU DAI and
platform drivers" from Jul 29, 2014, leads to the following Smatch
complaint:
sound/soc/fsl/fsl_asrc_dma.c:304 fsl_asrc_dma_shutdown()
warn: variable dereferenced before check 'pair' (see line 302)
sound/soc/fsl/fsl_asrc_dma.c
301 struct fsl_asrc_pair *pair = runtime->private_data;
302 struct fsl_asrc *asrc_priv = pair->asrc_priv;
^^^^^^^^^^^^^^^
Dereference.
303
304 if (pair && asrc_priv->pair[pair->index] == pair)
^^^^
Check.
305 asrc_priv->pair[pair->index] = NULL;
306
So we just let the driver check pair before using it.
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Nicolin Chen <nicoleotsuka@gmail.com>
---
sound/soc/fsl/fsl_asrc_dma.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/sound/soc/fsl/fsl_asrc_dma.c b/sound/soc/fsl/fsl_asrc_dma.c
index 5b1e73e..ffc000b 100644
--- a/sound/soc/fsl/fsl_asrc_dma.c
+++ b/sound/soc/fsl/fsl_asrc_dma.c
@@ -299,9 +299,14 @@ static int fsl_asrc_dma_shutdown(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime = substream->runtime;
struct fsl_asrc_pair *pair = runtime->private_data;
- struct fsl_asrc *asrc_priv = pair->asrc_priv;
+ struct fsl_asrc *asrc_priv;
+
+ if (!pair)
+ return 0;
+
+ asrc_priv = pair->asrc_priv;
- if (pair && asrc_priv->pair[pair->index] == pair)
+ if (asrc_priv->pair[pair->index] == pair)
asrc_priv->pair[pair->index] = NULL;
kfree(pair);
--
1.8.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] ASoC: fsl_asrc: Don't access members of config before checking it
2014-08-04 4:19 [PATCH 0/2] ASoC: fsl_asrc: Fix two dereferenced variable before check Nicolin Chen
2014-08-04 4:19 ` [PATCH 1/2] ASoC: fsl_sarc_dma: Check pair before using it Nicolin Chen
@ 2014-08-04 4:19 ` Nicolin Chen
2014-08-04 14:48 ` [PATCH 0/2] ASoC: fsl_asrc: Fix two dereferenced variable before check Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Nicolin Chen @ 2014-08-04 4:19 UTC (permalink / raw)
To: broonie; +Cc: alsa-devel, linuxppc-dev, linux-kernel, timur
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>
---
sound/soc/fsl/fsl_asrc.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c
index 06a96f3..86f45a1 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)
struct asrc_config *config = pair->config;
struct fsl_asrc *asrc_priv = pair->asrc_priv;
enum asrc_pair_index index = pair->index;
- u32 inrate = config->input_sample_rate, indiv;
- u32 outrate = config->output_sample_rate, outdiv;
- bool ideal = config->inclk == INCLK_NONE;
+ u32 inrate, outrate, indiv, outdiv;
u32 clk_index[2], div[2];
int in, out, channels;
struct clk *clk;
+ bool ideal;
if (!config) {
pair_err("invalid pair config\n");
@@ -264,6 +263,10 @@ static int fsl_asrc_config_pair(struct fsl_asrc_pair *pair)
return -EINVAL;
}
+ inrate = config->input_sample_rate;
+ outrate = config->output_sample_rate;
+ ideal = config->inclk == INCLK_NONE;
+
/* Validate input and output sample rates */
for (in = 0; in < ARRAY_SIZE(supported_input_rate); in++)
if (inrate == supported_input_rate[in])
--
1.8.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] ASoC: fsl_asrc: Fix two dereferenced variable before check
2014-08-04 4:19 [PATCH 0/2] ASoC: fsl_asrc: Fix two dereferenced variable before check Nicolin Chen
2014-08-04 4:19 ` [PATCH 1/2] ASoC: fsl_sarc_dma: Check pair before using it Nicolin Chen
2014-08-04 4:19 ` [PATCH 2/2] ASoC: fsl_asrc: Don't access members of config before checking it Nicolin Chen
@ 2014-08-04 14:48 ` Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2014-08-04 14:48 UTC (permalink / raw)
To: Nicolin Chen; +Cc: alsa-devel, linuxppc-dev, linux-kernel, timur
[-- Attachment #1: Type: text/plain, Size: 203 bytes --]
On Mon, Aug 04, 2014 at 12:19:47PM +0800, Nicolin Chen wrote:
> These two patches fixes two warning of dereferenced variable reported by
> Dan Carpenter <dan.carpenter@oracle.com>
Applied both, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-08-04 14:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-04 4:19 [PATCH 0/2] ASoC: fsl_asrc: Fix two dereferenced variable before check Nicolin Chen
2014-08-04 4:19 ` [PATCH 1/2] ASoC: fsl_sarc_dma: Check pair before using it Nicolin Chen
2014-08-04 4:19 ` [PATCH 2/2] ASoC: fsl_asrc: Don't access members of config before checking it Nicolin Chen
2014-08-04 14:48 ` [PATCH 0/2] ASoC: fsl_asrc: Fix two dereferenced variable before check Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).