Skip to contentSkip to conversation

tty: atmel_serial_probe(): index of atmel_ports[] fix

PATCH In review Pawel Wieczorkiewicz 2 participants 2 messages Feb 20, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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
index d4a7c24..3f7586a 100644
@@ -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
#1 lore raw
Quoted 15 lines · Pawel Wieczorkiewicz

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 +0 -0
index d4a7c24..3f7586a 100644

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