Commit 9fb9a352 authored by Johannes Berg's avatar Johannes Berg Committed by Kleber Sacilotto de Souza

ALSA: aoa: onyx: always initialize register read value

BugLink: https://bugs.launchpad.net/bugs/1864773

[ Upstream commit f474808a ]

A lot of places in the driver use onyx_read_register() without
checking the return value, and it's been working OK for ~10 years
or so, so probably never fails ... Rather than trying to check the
return value everywhere, which would be relatively intrusive, at
least make sure we don't use an uninitialized value.

Fixes: f3d9478b ("[ALSA] snd-aoa: add snd-aoa")
Reported-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: default avatarJohannes Berg <johannes@sipsolutions.net>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent 9ad23f03
...@@ -74,8 +74,10 @@ static int onyx_read_register(struct onyx *onyx, u8 reg, u8 *value) ...@@ -74,8 +74,10 @@ static int onyx_read_register(struct onyx *onyx, u8 reg, u8 *value)
return 0; return 0;
} }
v = i2c_smbus_read_byte_data(onyx->i2c, reg); v = i2c_smbus_read_byte_data(onyx->i2c, reg);
if (v < 0) if (v < 0) {
*value = 0;
return -1; return -1;
}
*value = (u8)v; *value = (u8)v;
onyx->cache[ONYX_REG_CONTROL-FIRSTREGISTER] = *value; onyx->cache[ONYX_REG_CONTROL-FIRSTREGISTER] = *value;
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment