Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tty: can327, move overflow test inside can327_ldisc_rx()'s loop

The 'count' is going to be unsigned and the 'count >= 0' test would be
always true then. Move the condition to the loop where this is easier to
check.

It looks as is easier to follow after all too.

Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Cc: Max Staudt <max@enpas.org>
Cc: Wolfgang Grandegger <wg@grandegger.com>
Cc: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: linux-can@vger.kernel.org
Link: https://lore.kernel.org/r/20230810091510.13006-15-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jiri Slaby (SUSE) and committed by
Greg Kroah-Hartman
73048bd5 94b580e3

+7 -8
+7 -8
drivers/net/can/can327.c
··· 901 901 */ 902 902 first_new_char_idx = elm->rxfill; 903 903 904 - while (count-- && elm->rxfill < CAN327_SIZE_RXBUF) { 904 + while (count--) { 905 + if (elm->rxfill >= CAN327_SIZE_RXBUF) { 906 + netdev_err(elm->dev, 907 + "Receive buffer overflowed. Bad chip or wiring? count = %i", 908 + count); 909 + goto uart_failure; 910 + } 905 911 if (fp && *fp++) { 906 912 netdev_err(elm->dev, 907 913 "Error in received character stream. Check your wiring."); ··· 934 928 } 935 929 936 930 cp++; 937 - } 938 - 939 - if (count >= 0) { 940 - netdev_err(elm->dev, 941 - "Receive buffer overflowed. Bad chip or wiring? count = %i", 942 - count); 943 - goto uart_failure; 944 931 } 945 932 946 933 can327_parse_rxbuf(elm, first_new_char_idx);