mirror of
https://github.com/edk2-porting/linux-next.git
synced 2025-01-22 12:33:59 +08:00
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>
This commit is contained in:
parent
c51d41a1dd
commit
503bded92d
@ -158,7 +158,7 @@ struct atmel_uart_port {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static struct atmel_uart_port atmel_ports[ATMEL_MAX_UART];
|
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
|
#ifdef SUPPORT_SYSRQ
|
||||||
static struct console atmel_console;
|
static struct console atmel_console;
|
||||||
@ -1769,15 +1769,14 @@ static int atmel_serial_probe(struct platform_device *pdev)
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
/* port id not found in platform data nor device-tree aliases:
|
/* port id not found in platform data nor device-tree aliases:
|
||||||
* auto-enumerate it */
|
* auto-enumerate it */
|
||||||
ret = find_first_zero_bit(&atmel_ports_in_use,
|
ret = find_first_zero_bit(atmel_ports_in_use, ATMEL_MAX_UART);
|
||||||
sizeof(atmel_ports_in_use));
|
|
||||||
|
|
||||||
if (ret > ATMEL_MAX_UART) {
|
if (ret >= ATMEL_MAX_UART) {
|
||||||
ret = -ENODEV;
|
ret = -ENODEV;
|
||||||
goto err;
|
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 */
|
/* port already in use */
|
||||||
ret = -EBUSY;
|
ret = -EBUSY;
|
||||||
goto err;
|
goto err;
|
||||||
@ -1857,7 +1856,7 @@ static int atmel_serial_remove(struct platform_device *pdev)
|
|||||||
|
|
||||||
/* "port" is allocated statically, so we shouldn't free it */
|
/* "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);
|
clk_put(atmel_port->clk);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user