summaryrefslogtreecommitdiffstats
path: root/drivers/tty
diff options
context:
space:
mode:
authorKrzysztof Kozlowski <k.kozlowski@samsung.com>2016-06-16 08:27:36 +0200
committerBen Hutchings <ben@decadent.org.uk>2016-11-20 01:16:42 +0000
commitffe0a2d68a63ae7fe324183d4b4fb354f0c10b7f (patch)
tree43184a057353abe1b0afcd96f92858f03d5a2f4c /drivers/tty
parent17461a139ad0766a5603a2de0e1da7d52303e9fa (diff)
downloadlinux-stable-ffe0a2d68a63ae7fe324183d4b4fb354f0c10b7f.tar.gz
linux-stable-ffe0a2d68a63ae7fe324183d4b4fb354f0c10b7f.tar.bz2
linux-stable-ffe0a2d68a63ae7fe324183d4b4fb354f0c10b7f.zip
serial: samsung: Fix possible out of bounds access on non-DT platform
commit 926b7b5122c96e1f18cd20e85a286c7ec8d18c97 upstream. On non-DeviceTree platforms, the index of serial device is a static variable incremented on each probe. It is incremented even if deferred probe happens when getting the clock in s3c24xx_serial_init_port(). This index is used for referencing elements of statically allocated s3c24xx_serial_ports array. In case of re-probe, the index will point outside of this array leading to memory corruption. Increment the index only on successful probe. Reported-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Fixes: b497549a035c ("[ARM] S3C24XX: Split serial driver into core and per-cpu drivers") Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'drivers/tty')
-rw-r--r--drivers/tty/serial/samsung.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
index 848892933ac7..2a2a54db86ff 100644
--- a/drivers/tty/serial/samsung.c
+++ b/drivers/tty/serial/samsung.c
@@ -1307,8 +1307,6 @@ static int s3c24xx_serial_probe(struct platform_device *pdev)
ourport->info->fifosize :
ourport->drv_data->fifosize[probe_index];
- probe_index++;
-
dbg("%s: initialising port %p...\n", __func__, ourport);
ret = s3c24xx_serial_init_port(ourport, pdev);
@@ -1344,6 +1342,8 @@ static int s3c24xx_serial_probe(struct platform_device *pdev)
if (ret < 0)
dev_err(&pdev->dev, "failed to add cpufreq notifier\n");
+ probe_index++;
+
return 0;
probe_err: