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>
This commit is contained in:
@@ -170,7 +170,7 @@ struct ak4114 {
|
||||
void * private_data;
|
||||
unsigned int init: 1;
|
||||
spinlock_t lock;
|
||||
unsigned char regmap[7];
|
||||
unsigned char regmap[6];
|
||||
unsigned char txcsb[5];
|
||||
struct snd_kcontrol *kctls[AK4114_CONTROLS];
|
||||
struct snd_pcm_substream *playback_substream;
|
||||
@@ -189,7 +189,7 @@ struct ak4114 {
|
||||
|
||||
int snd_ak4114_create(struct snd_card *card,
|
||||
ak4114_read_t *read, ak4114_write_t *write,
|
||||
const unsigned char pgm[7], const unsigned char txcsb[5],
|
||||
const unsigned char pgm[6], const unsigned char txcsb[5],
|
||||
void *private_data, struct ak4114 **r_ak4114);
|
||||
void snd_ak4114_reg_write(struct ak4114 *ak4114, unsigned char reg, unsigned char mask, unsigned char val);
|
||||
void snd_ak4114_reinit(struct ak4114 *ak4114);
|
||||
|
Reference in New Issue
Block a user