[2.6 patch] usb/input/keyspan_remote.c: don't use an uninitialized variable

From: Adrian Bunk
Date: Sat Mar 25 2006 - 12:09:59 EST


gcc reported the following:

<-- snip -->

...
CC drivers/usb/input/keyspan_remote.o
drivers/usb/input/keyspan_remote.c: In function 'keyspan_irq_recv':
drivers/usb/input/keyspan_remote.c:186: warning: 'message.toggle' may be used uninitialized in this function
...

<-- snip -->


gcc is right, there is an error case where this actually happens.

What about this patch that returns in this error case?

Signed-off-by: Darren Jenkins <darrenrjenkins@xxxxxxxxx>

--- linux-2.6.16-mm1-full/drivers/usb/input/keyspan_remote.c.old 2006-03-25 15:44:56.000000000 +0100
+++ linux-2.6.16-mm1-full/drivers/usb/input/keyspan_remote.c 2006-03-25 15:45:48.000000000 +0100
@@ -285,30 +285,31 @@ static void keyspan_check_data(struct us
return;
}
}

keyspan_load_tester(remote, 6);
if ((remote->data.tester & ZERO_MASK) == ZERO) {
message.toggle = 0;
remote->data.tester = remote->data.tester >> 5;
remote->data.bits_left -= 5;
} else if ((remote->data.tester & ONE_MASK) == ONE) {
message.toggle = 1;
remote->data.tester = remote->data.tester >> 6;
remote->data.bits_left -= 6;
} else {
err("%s - Error in message, invalid toggle.\n", __FUNCTION__);
+ return;
}

keyspan_load_tester(remote, 5);
if ((remote->data.tester & STOP_MASK) == STOP) {
remote->data.tester = remote->data.tester >> 5;
remote->data.bits_left -= 5;
} else {
err("Bad message recieved, no stop bit found.\n");
}

dev_dbg(&remote->udev->dev,
"%s found valid message: system: %d, button: %d, toggle: %d\n",
__FUNCTION__, message.system, message.button, message.toggle);

if (message.toggle != remote->toggle) {

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/