Skip to content

Commit 7d06c07

Browse files
LiHua-ProbeParkerWim Van Sebroeck
authored andcommitted
watchdog: pcwd_usb: Fix attempting to access uninitialized memory
The stack variable msb and lsb may be used uninitialized in function usb_pcwd_get_temperature and usb_pcwd_get_timeleft when usb card no response. The build waring is: drivers/watchdog/pcwd_usb.c:336:22: error: ‘lsb’ is used uninitialized in this function [-Werror=uninitialized] *temperature = (lsb * 9 / 5) + 32; ~~~~^~~ drivers/watchdog/pcwd_usb.c:328:21: note: ‘lsb’ was declared here unsigned char msb, lsb; ^~~ cc1: all warnings being treated as errors scripts/Makefile.build:250: recipe for target 'drivers/watchdog/pcwd_usb.o' failed make[3]: *** [drivers/watchdog/pcwd_usb.o] Error 1 Fixes: b7e04f8 ("mv watchdog tree under drivers") Signed-off-by: Li Hua <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]> Signed-off-by: Wim Van Sebroeck <[email protected]>
1 parent 7333185 commit 7d06c07

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/watchdog/pcwd_usb.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,8 @@ static int usb_pcwd_set_heartbeat(struct usb_pcwd_private *usb_pcwd, int t)
325325
static int usb_pcwd_get_temperature(struct usb_pcwd_private *usb_pcwd,
326326
int *temperature)
327327
{
328-
unsigned char msb, lsb;
328+
unsigned char msb = 0x00;
329+
unsigned char lsb = 0x00;
329330

330331
usb_pcwd_send_command(usb_pcwd, CMD_READ_TEMP, &msb, &lsb);
331332

@@ -341,7 +342,8 @@ static int usb_pcwd_get_temperature(struct usb_pcwd_private *usb_pcwd,
341342
static int usb_pcwd_get_timeleft(struct usb_pcwd_private *usb_pcwd,
342343
int *time_left)
343344
{
344-
unsigned char msb, lsb;
345+
unsigned char msb = 0x00;
346+
unsigned char lsb = 0x00;
345347

346348
/* Read the time that's left before rebooting */
347349
/* Note: if the board is not yet armed then we will read 0xFFFF */

0 commit comments

Comments
 (0)