Skip to contentSkip to conversation

tty: Fix potentialy used uninitialized variable

PATCH In review Tomer Barletz 2 participants 2 messages Aug 8, 2015 TTY layer and serial drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tty: Fix potentialy used uninitialized variable

Initialize size to 0, as it may be used uninitialized in case read_mem32() fails.

---
 drivers/tty/nozomi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/nozomi.c +1 -1
index 80f9de9..d70e9e4 100644
@@ -816,7 +816,7 @@ static int send_data(enum port_type index, struct nozomi *dc)
 static int receive_data(enum port_type index, struct nozomi *dc)
 {
 	u8 buf[RECEIVE_BUF_MAX] = { 0 };
-	int size;
+	int size = 0;
 	u32 offset = 4;
 	struct port *port = &dc->port[index];
 	void __iomem *addr = port->dl_addr[port->toggle_dl];
Signature · 1 line
2.4.3
#1 lore raw
Quoted 2 lines · Tomer Barletz

Initialize size to 0, as it may be used uninitialized in case read_mem32() fails.

Instead of papering over the issue better cleanup read_mem32() such that a failure can be detected. :-)

Signature · 2 lines
Thanks,
//richard