[media] pulse8-cec: avoid uninitialized data use
authorArnd Bergmann <arnd@arndb.de>
Mon, 12 Sep 2016 08:43:49 +0000 (05:43 -0300)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Mon, 19 Sep 2016 17:16:11 +0000 (14:16 -0300)
Building with -Wmaybe-uninitialized reveals the use on an uninitialized
variable containing the physical address of the device whenever
firmware before version 2 is used:

drivers/staging/media/pulse8-cec/pulse8-cec.c: In function 'pulse8_connect':
drivers/staging/media/pulse8-cec/pulse8-cec.c:447:2: error: 'pa' may be used uninitialized in this function [-Werror=maybe-uninitialized]

This sets the address to CEC_PHYS_ADDR_INVALID in this case, so we don't
try to write back the uninitialized data to the device.

Fixes: e28a6c8b3fcc ("[media] pulse8-cec: sync configuration with adapter")

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/staging/media/pulse8-cec/pulse8-cec.c

index 8292cab0f73bc3d20cb5da6adba74de7b966e889..9285765323f2eb05df958c034811de3865bd1a1b 100644 (file)
@@ -342,8 +342,10 @@ static int pulse8_setup(struct pulse8 *pulse8, struct serio *serio,
                return err;
        pulse8->vers = (data[0] << 8) | data[1];
        dev_info(pulse8->dev, "Firmware version %04x\n", pulse8->vers);
-       if (pulse8->vers < 2)
+       if (pulse8->vers < 2) {
+               *pa = CEC_PHYS_ADDR_INVALID;
                return 0;
+       }
 
        cmd[0] = MSGCODE_GET_BUILDDATE;
        err = pulse8_send_and_wait(pulse8, cmd, 1, cmd[0], 4);