From: Youngmin Nam Date: Mon, 17 Oct 2016 06:25:08 +0000 (+0900) Subject: [COMMON] serial: samsung: prevent UART port probe of exceeding max channel number X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=bc6f3c30e18b37f542b8f1ca6f33572ca4718d32;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git [COMMON] serial: samsung: prevent UART port probe of exceeding max channel number This patch prevents UART port probing when the UART port number exceeds UART max channel numbers. Change-Id: Ia4d0ee85fd240ec4e83107a3e67d66797e1733fd Signed-off-by: Youngmin Nam --- diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c index 337cde7bec95..72c654fb8ffa 100644 --- a/drivers/tty/serial/samsung.c +++ b/drivers/tty/serial/samsung.c @@ -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");