[PATCH] Fix Specialix SX corruption
authorMarc Zyngier <maz@misterjones.org>
Mon, 27 Feb 2006 11:08:00 +0000 (12:08 +0100)
committerLinus Torvalds <torvalds@g5.osdl.org>
Mon, 27 Feb 2006 16:18:04 +0000 (08:18 -0800)
With the latest kernels, I experienced some strange corruption, some
'*****' being randomly inserted in the character flow, like this:

ashes:~#
ashes:~#
a*******shes:~#
ashes:~#
ashes:~#

Further investigation shows that the problem was introduced during
Alan's "TTY layer buffering revamp" patch, the amount of data to be
copied being reduced after buffer allocation.  Moving the count fixup
around solves the problem.

Signed-off-by: Marc Zyngier <maz@misterjones.org>
Approved-by: Rogier Wolff <R.E.Wolff@BitWizard.nl>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/char/sx.c

index 588e75ec16309c5086e36895f1bb96cd3f0170a8..a6b4f02bdceb06ba347d5241f6b479eacecbb36a 100644 (file)
@@ -1095,17 +1095,17 @@ static inline void sx_receive_chars (struct sx_port *port)
 
                sx_dprintk (SX_DEBUG_RECEIVE, "rxop=%d, c = %d.\n", rx_op, c); 
 
+               /* Don't copy past the end of the hardware receive buffer */
+               if (rx_op + c > 0x100) c = 0x100 - rx_op;
+
+               sx_dprintk (SX_DEBUG_RECEIVE, "c = %d.\n", c);
+
                /* Don't copy more bytes than there is room for in the buffer */
 
                c = tty_prepare_flip_string(tty, &rp, c);
 
                sx_dprintk (SX_DEBUG_RECEIVE, "c = %d.\n", c); 
 
-               /* Don't copy past the end of the hardware receive buffer */
-               if (rx_op + c > 0x100) c = 0x100 - rx_op;
-
-               sx_dprintk (SX_DEBUG_RECEIVE, "c = %d.\n", c);
-
                /* If for one reason or another, we can't copy more data, we're done! */
                if (c == 0) break;