[COMMON] serial: samsung: prevent UART port probe of exceeding max channel number
authorYoungmin Nam <youngmin.nam@samsung.com>
Mon, 17 Oct 2016 06:25:08 +0000 (15:25 +0900)
committermyung-su.cha <myung-su.cha@samsung.com>
Wed, 9 May 2018 12:14:45 +0000 (21:14 +0900)
This patch prevents UART port probing when the UART port number exceeds
UART max channel numbers.

Change-Id: Ia4d0ee85fd240ec4e83107a3e67d66797e1733fd
Signed-off-by: Youngmin Nam <youngmin.nam@samsung.com>
drivers/tty/serial/samsung.c

index 337cde7bec95bfc5ac4bf0a07fb972aaa75177ad..72c654fb8ffabd955d45ddac615032f818ba4821 100644 (file)
@@ -1552,6 +1552,13 @@ static int s3c24xx_serial_probe(struct platform_device *pdev)
        if (ourport->port.line != port_index)
                ourport = exynos_serial_default_port(port_index);
 
+       if (ourport->port.line >= CONFIG_SERIAL_SAMSUNG_UARTS) {
+               dev_err(&pdev->dev,
+                       "the port %d exceeded CONFIG_SERIAL_SAMSUNG_UARTS(%d)\n"
+                       , ourport->port.line, CONFIG_SERIAL_SAMSUNG_UARTS);
+               return -EINVAL;
+       }
+
        ourport->drv_data = s3c24xx_get_driver_data(pdev);
        if (!ourport->drv_data) {
                dev_err(&pdev->dev, "could not find driver data\n");