Skip to contentSkip to conversation

ALSA: aoa: onyx: always initalize register read value

PATCH Applied Johannes Berg 2 participants 2 messages Jul 29, 2019

Subsystems (2)
lore
Share & tools
lore

Johannes Berg

author maintainer
#0 lore raw

PATCH 1/1 ALSA: aoa: onyx: always initalize register read value

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.

---
 sound/aoa/codecs/onyx.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
sound/aoa/codecs/onyx.c +3 -1
index db917546965d..9827bee109c1 100644
@@ -71,8 +71,10 @@ static int onyx_read_register(struct onyx *onyx, u8 reg, u8 *value)
 		return 0;
 	}
 	v = i2c_smbus_read_byte_data(onyx->i2c, reg);
-	if (v < 0)
+	if (v < 0) {
+		*value = 0;
 		return -1;
+	}
 	*value = (u8)v;
 	onyx->cache[ONYX_REG_CONTROL-FIRSTREGISTER] = *value;
 	return 0;
Signature · 1 line
2.20.1
Applied
#1 lore raw
Quoted 9 lines · Johannes Berg

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.

Thanks, applied now with a correction of a typo in the subject line and Fixes tag.

Takashi