Skip to content

Commit

Permalink
ASoC: fix ak4104 register array access
Browse files Browse the repository at this point in the history
Don't touch the variable 'reg' to construct the value for the actual SPI
transport. This variable is again used to access the driver's register
cache, and so random memory is overwritten.
Compute the value in-place instead.

Signed-off-by: Daniel Mack <daniel@caiaq.de>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Cc: stable@kernel.org
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
  • Loading branch information
Daniel Mack authored and Mark Brown committed Mar 3, 2010
1 parent bb1c047 commit e555317
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions sound/soc/codecs/ak4104.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,10 @@ static int ak4104_spi_write(struct snd_soc_codec *codec, unsigned int reg,
if (reg >= codec->reg_cache_size)
return -EINVAL;

reg &= AK4104_REG_MASK;
reg |= AK4104_WRITE;

/* only write to the hardware if value has changed */
if (cache[reg] != value) {
u8 tmp[2] = { reg, value };
u8 tmp[2] = { (reg & AK4104_REG_MASK) | AK4104_WRITE, value };

if (spi_write(spi, tmp, sizeof(tmp))) {
dev_err(&spi->dev, "SPI write failed\n");
return -EIO;
Expand Down

0 comments on commit e555317

Please sign in to comment.