]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ALSA: aoa: onyx: always initialize register read value
authorJohannes Berg <johannes@sipsolutions.net>
Mon, 29 Jul 2019 07:14:22 +0000 (09:14 +0200)
committerBen Hutchings <ben@decadent.org.uk>
Tue, 10 Dec 2019 18:01:11 +0000 (18:01 +0000)
commit f474808acb3c4b30552d9c59b181244e0300d218 upstream.

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: f3d9478b2ce4 ("[ALSA] snd-aoa: add snd-aoa")
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
sound/aoa/codecs/onyx.c

index 401107b85d300afa972a3cdc858311865cd56699..01678e989ebb77114a55163c02d4c8f5aceec4b7 100644 (file)
@@ -74,8 +74,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;