diff options
| author | Takashi Iwai <tiwai@suse.de> | 2013-10-29 11:37:11 -0400 |
|---|---|---|
| committer | Takashi Iwai <tiwai@suse.de> | 2013-10-29 11:42:36 -0400 |
| commit | e12483e0f3dbc32dad8fa1dc97efac22b6aee94f (patch) | |
| tree | 53207314a9b65a25832427e0d835032f132f1ecc /include/sound | |
| parent | 2026d24ef2ea8caad5e87662a58075e930ccab63 (diff) | |
ALSA: ak4114: Fix wrong register array size
The size of the register cache array is actually 6 instead of 7,
as it caches up to AK4114_REG_INT1_MASK. This resulted in unexpected
access out of array range, although most of them aren't so serious
(just reading one more byte on the stack at snd_ak4114_create()).
Also, the check of cache size was wrongly done by checking with
sizeof() instead of ARRAY_SIZE(). Fixed this together.
(And yes, hardcoded numbers are bad, but I keep the coding style as is
for making it clear what this patch actually does.)
Spotted by coverity among several CIDs, e.g. 711621.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'include/sound')
| -rw-r--r-- | include/sound/ak4114.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/include/sound/ak4114.h b/include/sound/ak4114.h index 3ce69fd92523..52f02a60dba7 100644 --- a/include/sound/ak4114.h +++ b/include/sound/ak4114.h | |||
| @@ -170,7 +170,7 @@ struct ak4114 { | |||
| 170 | void * private_data; | 170 | void * private_data; |
| 171 | unsigned int init: 1; | 171 | unsigned int init: 1; |
| 172 | spinlock_t lock; | 172 | spinlock_t lock; |
| 173 | unsigned char regmap[7]; | 173 | unsigned char regmap[6]; |
| 174 | unsigned char txcsb[5]; | 174 | unsigned char txcsb[5]; |
| 175 | struct snd_kcontrol *kctls[AK4114_CONTROLS]; | 175 | struct snd_kcontrol *kctls[AK4114_CONTROLS]; |
| 176 | struct snd_pcm_substream *playback_substream; | 176 | struct snd_pcm_substream *playback_substream; |
| @@ -189,7 +189,7 @@ struct ak4114 { | |||
| 189 | 189 | ||
| 190 | int snd_ak4114_create(struct snd_card *card, | 190 | int snd_ak4114_create(struct snd_card *card, |
| 191 | ak4114_read_t *read, ak4114_write_t *write, | 191 | ak4114_read_t *read, ak4114_write_t *write, |
| 192 | const unsigned char pgm[7], const unsigned char txcsb[5], | 192 | const unsigned char pgm[6], const unsigned char txcsb[5], |
| 193 | void *private_data, struct ak4114 **r_ak4114); | 193 | void *private_data, struct ak4114 **r_ak4114); |
| 194 | void snd_ak4114_reg_write(struct ak4114 *ak4114, unsigned char reg, unsigned char mask, unsigned char val); | 194 | void snd_ak4114_reg_write(struct ak4114 *ak4114, unsigned char reg, unsigned char mask, unsigned char val); |
| 195 | void snd_ak4114_reinit(struct ak4114 *ak4114); | 195 | void snd_ak4114_reinit(struct ak4114 *ak4114); |
