ASoC: Intel: Fix a buffer overflow issue
authorJie Yang <yang.jie@intel.com>
Tue, 7 Apr 2015 12:14:59 +0000 (20:14 +0800)
committerMark Brown <broonie@kernel.org>
Wed, 8 Apr 2015 10:17:51 +0000 (11:17 +0100)
0day robot reported a buffer overflow issue:

...
sound/soc/intel/haswell/sst-haswell-pcm.c:1107 hsw_pcm_probe() error: buffer\
overflow 'hsw_dais' 4 <= 4
sound/soc/intel/haswell/sst-haswell-pcm.c:1109 hsw_pcm_probe() error: buffer\
overflow 'hsw_dais' 4 <= 4
...

Fix it by initializing the index(i) to correct value.

Signed-off-by: Jie Yang <yang.jie@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/intel/haswell/sst-haswell-pcm.c

index 157b3a6c509eccdfec3847db31eae5dd9d360eb2..23ae0400d6db99668b3d2b48b47eb003d2fc2e46 100644 (file)
@@ -1103,7 +1103,7 @@ static int hsw_pcm_probe(struct snd_soc_platform *platform)
        return 0;
 
 err:
-       for (;i >= 0; i--) {
+       for (--i; i >= 0; i--) {
                if (hsw_dais[i].playback.channels_min)
                        snd_dma_free_pages(&priv_data->dmab[i][0]);
                if (hsw_dais[i].capture.channels_min)