Skip to contentSkip to conversation

staging: greybus: uart: fix uninitialized newline.flow_control

PATCH In review Colin King 2 participants 2 messages Feb 9, 2017

Subsystems (3)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 staging: greybus: uart: fix uninitialized newline.flow_control

From: Colin Ian King <[email protected]>

Currently newline.flow_control is uninitialized, so it can contain any garbage from the stack. I believe it should be initialized with GB_SERIAL_AUTO_RTSCTS_EN enabled if the termios c_cflag is CRTSCTS enabled.

---
 drivers/staging/greybus/uart.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/staging/greybus/uart.c +2 -0
index 248ad66..b542f67 100644
@@ -506,6 +506,8 @@ static void gb_tty_set_termios(struct tty_struct *tty,
 	newline.parity = termios->c_cflag & PARENB ?
 				(termios->c_cflag & PARODD ? 1 : 2) +
 				(termios->c_cflag & CMSPAR ? 2 : 0) : 0;
+	newline.flow_control = termios->c_cflag & CRTSCTS ?
+				GB_SERIAL_AUTO_RTSCTS_EN : 0;
 
 	switch (termios->c_cflag & CSIZE) {
 	case CS5:
Signature · 1 line
2.10.2
maintainer
#1 lore raw
Quoted 6 lines · Colin King

From: Colin Ian King <[email protected]>

Currently newline.flow_control is uninitialized, so it can contain any garbage from the stack. I believe it should be initialized with GB_SERIAL_AUTO_RTSCTS_EN enabled if the termios c_cflag is CRTSCTS enabled.

Good catch. The CRTSCTS flag is actually honoured a bit further down in the set_termios(), but there's a bug in that it assumes newline to have been initialised with the current (old) values. It should unconditionally set the flow_control field rather than manipulate bits (we currently use one bit of this field).

Care to send a v2 fixing this up as suggested above?

Thanks,
Johan