[12/74] tty: atmel_serial_probe(): index of atmel_ports[] fix

2013-04-07 Thread Ben Hutchings
3.2.43-rc1 review patch.  If anyone has any objections, please let me know.

--

From: Pawel Wieczorkiewicz 

commit 503bded92da283b2f31d87e054c4c6d30c3c2340 upstream.

Index of atmel_ports[ATMEL_MAX_UART] should be smaller
than ATMEL_MAX_UART.

Signed-off-by: Pawel Wieczorkiewicz 
Acked-by: Nicolas Ferre 
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Ben Hutchings 
---
 drivers/tty/serial/atmel_serial.c |   11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

--- a/drivers/tty/serial/atmel_serial.c
+++ b/drivers/tty/serial/atmel_serial.c
@@ -159,7 +159,7 @@ struct atmel_uart_port {
 };
 
 static struct atmel_uart_port atmel_ports[ATMEL_MAX_UART];
-static unsigned long atmel_ports_in_use;
+static DECLARE_BITMAP(atmel_ports_in_use, ATMEL_MAX_UART);
 
 #ifdef SUPPORT_SYSRQ
 static struct console atmel_console;
@@ -1784,15 +1784,14 @@ static int __devinit atmel_serial_probe(
if (ret < 0)
/* port id not found in platform data nor device-tree aliases:
 * auto-enumerate it */
-   ret = find_first_zero_bit(_ports_in_use,
-   sizeof(atmel_ports_in_use));
+   ret = find_first_zero_bit(atmel_ports_in_use, ATMEL_MAX_UART);
 
-   if (ret > ATMEL_MAX_UART) {
+   if (ret >= ATMEL_MAX_UART) {
ret = -ENODEV;
goto err;
}
 
-   if (test_and_set_bit(ret, _ports_in_use)) {
+   if (test_and_set_bit(ret, atmel_ports_in_use)) {
/* port already in use */
ret = -EBUSY;
goto err;
@@ -1866,7 +1865,7 @@ static int __devexit atmel_serial_remove
 
/* "port" is allocated statically, so we shouldn't free it */
 
-   clear_bit(port->line, _ports_in_use);
+   clear_bit(port->line, atmel_ports_in_use);
 
clk_put(atmel_port->clk);
 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[12/74] tty: atmel_serial_probe(): index of atmel_ports[] fix

2013-04-07 Thread Ben Hutchings
3.2.43-rc1 review patch.  If anyone has any objections, please let me know.

--

From: Pawel Wieczorkiewicz wpa...@gmail.com

commit 503bded92da283b2f31d87e054c4c6d30c3c2340 upstream.

Index of atmel_ports[ATMEL_MAX_UART] should be smaller
than ATMEL_MAX_UART.

Signed-off-by: Pawel Wieczorkiewicz wpa...@gmail.com
Acked-by: Nicolas Ferre nicolas.fe...@atmel.com
Signed-off-by: Greg Kroah-Hartman gre...@linuxfoundation.org
Signed-off-by: Ben Hutchings b...@decadent.org.uk
---
 drivers/tty/serial/atmel_serial.c |   11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

--- a/drivers/tty/serial/atmel_serial.c
+++ b/drivers/tty/serial/atmel_serial.c
@@ -159,7 +159,7 @@ struct atmel_uart_port {
 };
 
 static struct atmel_uart_port atmel_ports[ATMEL_MAX_UART];
-static unsigned long atmel_ports_in_use;
+static DECLARE_BITMAP(atmel_ports_in_use, ATMEL_MAX_UART);
 
 #ifdef SUPPORT_SYSRQ
 static struct console atmel_console;
@@ -1784,15 +1784,14 @@ static int __devinit atmel_serial_probe(
if (ret  0)
/* port id not found in platform data nor device-tree aliases:
 * auto-enumerate it */
-   ret = find_first_zero_bit(atmel_ports_in_use,
-   sizeof(atmel_ports_in_use));
+   ret = find_first_zero_bit(atmel_ports_in_use, ATMEL_MAX_UART);
 
-   if (ret  ATMEL_MAX_UART) {
+   if (ret = ATMEL_MAX_UART) {
ret = -ENODEV;
goto err;
}
 
-   if (test_and_set_bit(ret, atmel_ports_in_use)) {
+   if (test_and_set_bit(ret, atmel_ports_in_use)) {
/* port already in use */
ret = -EBUSY;
goto err;
@@ -1866,7 +1865,7 @@ static int __devexit atmel_serial_remove
 
/* port is allocated statically, so we shouldn't free it */
 
-   clear_bit(port-line, atmel_ports_in_use);
+   clear_bit(port-line, atmel_ports_in_use);
 
clk_put(atmel_port-clk);
 

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/