linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: greybus: uart: fix uninitialized newline.flow_control
@ 2017-02-09 13:01 Colin King
  2017-02-09 16:45 ` Johan Hovold
  0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2017-02-09 13:01 UTC (permalink / raw)
  To: David Lin, Johan Hovold, Alex Elder, Greg Kroah-Hartman,
	greybus-dev, devel
  Cc: linux-kernel

From: Colin Ian King <colin.king@canonical.com>

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.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/staging/greybus/uart.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/greybus/uart.c b/drivers/staging/greybus/uart.c
index 248ad66..b542f67 100644
--- a/drivers/staging/greybus/uart.c
+++ b/drivers/staging/greybus/uart.c
@@ -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:
-- 
2.10.2

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] staging: greybus: uart: fix uninitialized newline.flow_control
  2017-02-09 13:01 [PATCH] staging: greybus: uart: fix uninitialized newline.flow_control Colin King
@ 2017-02-09 16:45 ` Johan Hovold
  0 siblings, 0 replies; 2+ messages in thread
From: Johan Hovold @ 2017-02-09 16:45 UTC (permalink / raw)
  To: Colin King
  Cc: David Lin, Johan Hovold, Alex Elder, Greg Kroah-Hartman,
	greybus-dev, devel, linux-kernel

On Thu, Feb 09, 2017 at 01:01:18PM +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-02-09 16:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-09 13:01 [PATCH] staging: greybus: uart: fix uninitialized newline.flow_control Colin King
2017-02-09 16:45 ` Johan Hovold

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).