tty: atmel_serial_probe(): index of atmel_ports[] fix
Subsystems (3)
PATCH 1/1 tty: atmel_serial_probe(): index of atmel_ports[] fix
From: Pawel Wieczorkiewicz <[email protected]>
Index of atmel_ports[ATMEL_MAX_UART] should be smaller than ATMEL_MAX_UART.
--- drivers/tty/serial/atmel_serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/atmel_serial.c +1 -1
@@ -1772,7 +1772,7 @@ static int atmel_serial_probe(struct platform_device *pdev) ret =find_first_zero_bit (&atmel_ports_in_use,sizeof (atmel_ports_in_use)); -if (ret >ATMEL_MAX_UART ) { +if (!(ret <ATMEL_MAX_UART )) { ret = -ENODEV ; goto err; }
Signature · 1 line
1.7.9.5
Quoted 15 lines · Pawel Wieczorkiewicz
From: Pawel Wieczorkiewicz <[email protected]>
Index of atmel_ports[ATMEL_MAX_UART] should be smaller than
ATMEL_MAX_UART.Signed-off-by Pawel Wieczorkiewicz <[email protected]>--- drivers/tty/serial/atmel_serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/tty/serial/atmel_serial.c +0
-0
drivers/tty/serial/atmel_serial.c static int atmel_serial_probe(struct platform_device *pdev) · line 1775
Quoted 5 lines
drivers/tty/serial/atmel_serial.c +1
-1@@ -1772,7 +1772,7 @@ static int atmel_serial_probe(struct platform_device *pdev) ret =find_first_zero_bit (&atmel_ports_in_use,sizeof (atmel_ports_in_use)); -if (ret >ATMEL_MAX_UART ) { +if (!(ret <ATMEL_MAX_UART )) {
Good catch, but the result looks weird. Could you just make it ">="?
And find_first_zero_bit + sizeof above is bogus too. The sizeof returns 4 on 32-bit (the driver is run on 32bit machines exlusively AFAICS). So the highest possible ret in there is 5. Instead atmel_ports_in_use should be declared using DECLARE_BITMAP(atmel_ports_in_use, ATMEL_MAX_UART) and the second parameter here then ATMEL_MAX_UART.
Could you fix that too?
Signature · 2 lines
js suse labs