* [PATCH] serial: 8250_core: use pre-decrement for iteration limit
@ 2014-10-13 15:09 Frans Klaver
2014-10-14 11:52 ` Frans Klaver
2014-11-06 20:10 ` [PATCH v2] serial: 8250_core: actually limit char reads to max_count Frans Klaver
0 siblings, 2 replies; 4+ messages in thread
From: Frans Klaver @ 2014-10-13 15:09 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Frans Klaver, Jiri Slaby, linux-serial, linux-kernel
In serial8250_rx_chars(), max_count is set to 256. Due to the
post-decrement operator used in the while() condition, the maximum
number of iterations actually 257. This is not a problem, but it is
mildly surprising if you're debugging. Use pre-decrement instead.
Signed-off-by: Frans Klaver <frans.klaver@xsens.com>
---
drivers/tty/serial/8250/8250_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
index a06084d..cc9f1a8 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -1485,7 +1485,7 @@ serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr)
ignore_char:
lsr = serial_in(up, UART_LSR);
- } while ((lsr & (UART_LSR_DR | UART_LSR_BI)) && (max_count-- > 0));
+ } while ((lsr & (UART_LSR_DR | UART_LSR_BI)) && (--max_count > 0));
spin_unlock(&port->lock);
tty_flip_buffer_push(&port->state->port);
spin_lock(&port->lock);
--
2.1.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] serial: 8250_core: use pre-decrement for iteration limit
2014-10-13 15:09 [PATCH] serial: 8250_core: use pre-decrement for iteration limit Frans Klaver
@ 2014-10-14 11:52 ` Frans Klaver
2014-11-06 18:32 ` Greg Kroah-Hartman
2014-11-06 20:10 ` [PATCH v2] serial: 8250_core: actually limit char reads to max_count Frans Klaver
1 sibling, 1 reply; 4+ messages in thread
From: Frans Klaver @ 2014-10-14 11:52 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Jiri Slaby, linux-serial, linux-kernel
On Mon, Oct 13, 2014 at 05:09:11PM +0200, Frans Klaver wrote:
> In serial8250_rx_chars(), max_count is set to 256. Due to the
> post-decrement operator used in the while() condition, the maximum
> number of iterations actually 257. This is not a problem, but it is
> mildly surprising if you're debugging. Use pre-decrement instead.
I'm somewhat inclined to changing the title to something like:
serial: 8250_core: actually limit char reads to max_count
Frans
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] serial: 8250_core: use pre-decrement for iteration limit
2014-10-14 11:52 ` Frans Klaver
@ 2014-11-06 18:32 ` Greg Kroah-Hartman
0 siblings, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2014-11-06 18:32 UTC (permalink / raw)
To: Frans Klaver; +Cc: Jiri Slaby, linux-serial, linux-kernel
On Tue, Oct 14, 2014 at 01:52:34PM +0200, Frans Klaver wrote:
> On Mon, Oct 13, 2014 at 05:09:11PM +0200, Frans Klaver wrote:
> > In serial8250_rx_chars(), max_count is set to 256. Due to the
> > post-decrement operator used in the while() condition, the maximum
> > number of iterations actually 257. This is not a problem, but it is
> > mildly surprising if you're debugging. Use pre-decrement instead.
>
> I'm somewhat inclined to changing the title to something like:
>
> serial: 8250_core: actually limit char reads to max_count
Sounds better, care to resend with that subject:?
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] serial: 8250_core: actually limit char reads to max_count
2014-10-13 15:09 [PATCH] serial: 8250_core: use pre-decrement for iteration limit Frans Klaver
2014-10-14 11:52 ` Frans Klaver
@ 2014-11-06 20:10 ` Frans Klaver
1 sibling, 0 replies; 4+ messages in thread
From: Frans Klaver @ 2014-11-06 20:10 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Frans Klaver, Jiri Slaby, linux-serial, linux-kernel
In serial8250_rx_chars(), max_count is set to 256. Due to the
post-decrement operator used in the while() condition, the maximum
number of iterations actually 257. This is not a problem, but it is
mildly surprising if you're debugging. Use pre-decrement instead.
Signed-off-by: Frans Klaver <frans.klaver@xsens.com>
---
v1..v2: change subject to better reflect the goal of the patch
drivers/tty/serial/8250/8250_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
index a06084d..cc9f1a8 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -1485,7 +1485,7 @@ serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr)
ignore_char:
lsr = serial_in(up, UART_LSR);
- } while ((lsr & (UART_LSR_DR | UART_LSR_BI)) && (max_count-- > 0));
+ } while ((lsr & (UART_LSR_DR | UART_LSR_BI)) && (--max_count > 0));
spin_unlock(&port->lock);
tty_flip_buffer_push(&port->state->port);
spin_lock(&port->lock);
--
2.1.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-11-06 20:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-13 15:09 [PATCH] serial: 8250_core: use pre-decrement for iteration limit Frans Klaver
2014-10-14 11:52 ` Frans Klaver
2014-11-06 18:32 ` Greg Kroah-Hartman
2014-11-06 20:10 ` [PATCH v2] serial: 8250_core: actually limit char reads to max_count Frans Klaver
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).