Skip to contentSkip to conversation

serial: amba-pl011: fix incorrect integer size in pl011_fifo_to_tty()

PATCH In review Timur Tabi 3 participants 3 messages Oct 7, 2015 – Oct 23, 2015

Subsystems (2)
lore
Share & tools
lore

Timur Tabi

author
#0 lore raw

PATCH 1/1 serial: amba-pl011: fix incorrect integer size in pl011_fifo_to_tty()

The UART_DUMMY_DR_RX status bit is equal to (1 << 16), so a u16 is too small to hold that value. The result is that UART_DUMMY_DR_RX is never passed to uart_insert_char(). This means that we're always accepting characters, even when CREAD (in termios) is not set.

---
 drivers/tty/serial/amba-pl011.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/serial/amba-pl011.c +2 -2
index fd27e98..899a771 100644
@@ -191,8 +191,8 @@ struct uart_amba_port {
  */
 static int pl011_fifo_to_tty(struct uart_amba_port *uap)
 {
-	u16 status, ch;
-	unsigned int flag, max_count = 256;
+	u16 status;
+	unsigned int ch, flag, max_count = 256;
 	int fifotaken = 0;
 
 	while (max_count--) {
Signature · 3 lines
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project.
Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines · Timur Tabi

The UART_DUMMY_DR_RX status bit is equal to (1 << 16), so a u16 is too small to hold that value. The result is that UART_DUMMY_DR_RX is never passed to uart_insert_char(). This means that we're always accepting characters, even when CREAD (in termios) is not set.

---
 drivers/tty/serial/amba-pl011.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/serial/amba-pl011.c +0 -0
index fd27e98..899a771 100644

drivers/tty/serial/amba-pl011.c struct uart_amba_port { · line 196

Quoted 8 lines
drivers/tty/serial/amba-pl011.c +2 -2
@@ -191,8 +191,8 @@ struct uart_amba_port {
  */
 static int pl011_fifo_to_tty(struct uart_amba_port *uap)
 {
-	u16 status, ch;
-	unsigned int flag, max_count = 256;
+	u16 status;
+	unsigned int ch, flag, max_count = 256;
 	int fifotaken = 0;

FWIW,

I guess this tells us something about how often !CREAD is used...

Cheers
---Dave