diff options
author | Pawel Wieczorkiewicz <wpawel@gmail.com> | 2013-02-20 11:26:20 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-03-15 16:23:29 -0400 |
commit | 503bded92da283b2f31d87e054c4c6d30c3c2340 (patch) | |
tree | 9c959a78eacb0afd4bea2fb8dc5b337dba63473a | |
parent | c51d41a1dd8f23a06a4ed651ebb9617de7f59368 (diff) |
tty: atmel_serial_probe(): index of atmel_ports[] fix
Index of atmel_ports[ATMEL_MAX_UART] should be smaller
than ATMEL_MAX_UART.
Signed-off-by: Pawel Wieczorkiewicz <wpawel@gmail.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/tty/serial/atmel_serial.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c index d4a7c241b751..3467462869ce 100644 --- a/drivers/tty/serial/atmel_serial.c +++ b/drivers/tty/serial/atmel_serial.c | |||
@@ -158,7 +158,7 @@ struct atmel_uart_port { | |||
158 | }; | 158 | }; |
159 | 159 | ||
160 | static struct atmel_uart_port atmel_ports[ATMEL_MAX_UART]; | 160 | static struct atmel_uart_port atmel_ports[ATMEL_MAX_UART]; |
161 | static unsigned long atmel_ports_in_use; | 161 | static DECLARE_BITMAP(atmel_ports_in_use, ATMEL_MAX_UART); |
162 | 162 | ||
163 | #ifdef SUPPORT_SYSRQ | 163 | #ifdef SUPPORT_SYSRQ |
164 | static struct console atmel_console; | 164 | static struct console atmel_console; |
@@ -1769,15 +1769,14 @@ static int atmel_serial_probe(struct platform_device *pdev) | |||
1769 | if (ret < 0) | 1769 | if (ret < 0) |
1770 | /* port id not found in platform data nor device-tree aliases: | 1770 | /* port id not found in platform data nor device-tree aliases: |
1771 | * auto-enumerate it */ | 1771 | * auto-enumerate it */ |
1772 | ret = find_first_zero_bit(&atmel_ports_in_use, | 1772 | ret = find_first_zero_bit(atmel_ports_in_use, ATMEL_MAX_UART); |
1773 | sizeof(atmel_ports_in_use)); | ||
1774 | 1773 | ||
1775 | if (ret > ATMEL_MAX_UART) { | 1774 | if (ret >= ATMEL_MAX_UART) { |
1776 | ret = -ENODEV; | 1775 | ret = -ENODEV; |
1777 | goto err; | 1776 | goto err; |
1778 | } | 1777 | } |
1779 | 1778 | ||
1780 | if (test_and_set_bit(ret, &atmel_ports_in_use)) { | 1779 | if (test_and_set_bit(ret, atmel_ports_in_use)) { |
1781 | /* port already in use */ | 1780 | /* port already in use */ |
1782 | ret = -EBUSY; | 1781 | ret = -EBUSY; |
1783 | goto err; | 1782 | goto err; |
@@ -1857,7 +1856,7 @@ static int atmel_serial_remove(struct platform_device *pdev) | |||
1857 | 1856 | ||
1858 | /* "port" is allocated statically, so we shouldn't free it */ | 1857 | /* "port" is allocated statically, so we shouldn't free it */ |
1859 | 1858 | ||
1860 | clear_bit(port->line, &atmel_ports_in_use); | 1859 | clear_bit(port->line, atmel_ports_in_use); |
1861 | 1860 | ||
1862 | clk_put(atmel_port->clk); | 1861 | clk_put(atmel_port->clk); |
1863 | 1862 | ||