serial: samsung: Fix possible out of bounds access on non-DT platform
[pandora-kernel.git] / drivers / tty / serial / samsung.c
index b31f1c3..808d171 100644 (file)
@@ -519,11 +519,15 @@ static void s3c24xx_serial_pm(struct uart_port *port, unsigned int level,
                              unsigned int old)
 {
        struct s3c24xx_uart_port *ourport = to_ourport(port);
+       int timeout = 10000;
 
        ourport->pm_level = level;
 
        switch (level) {
        case 3:
+               while (--timeout && !s3c24xx_serial_txempty_nofifo(port))
+                       udelay(100);
+
                if (!IS_ERR(ourport->baudclk) && ourport->baudclk != NULL)
                        clk_disable(ourport->baudclk);
 
@@ -1233,8 +1237,6 @@ int s3c24xx_serial_probe(struct platform_device *dev,
        dbg("s3c24xx_serial_probe(%p, %p) %d\n", dev, info, probe_index);
 
        ourport = &s3c24xx_serial_ports[probe_index];
-       probe_index++;
-
        dbg("%s: initialising port %p...\n", __func__, ourport);
 
        ret = s3c24xx_serial_init_port(ourport, info, dev);
@@ -1271,6 +1273,8 @@ int __devexit s3c24xx_serial_remove(struct platform_device *dev)
                uart_remove_one_port(&s3c24xx_uart_drv, port);
        }
 
+       probe_index++;
+
        return 0;
 }