ARM: OMAP1: ams-delta: Fix possible use of uninitialized field
authorJanusz Krzysztofik <jmkrzyszt@gmail.com>
Wed, 7 Nov 2018 21:30:31 +0000 (22:30 +0100)
committerTony Lindgren <tony@atomide.com>
Thu, 8 Nov 2018 17:25:44 +0000 (09:25 -0800)
While playing with initialization order of modem device, it has been
discovered that under some circumstances (early console init, I
believe) its .pm() callback may be called before the
uart_port->private_data pointer is initialized from
plat_serial8250_port->private_data, resulting in NULL pointer
dereference.  Fix it by checking for uninitialized pointer before using
it in modem_pm().

Fixes: aabf31737a6a ("ARM: OMAP1: ams-delta: update the modem to use regulator API")
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
arch/arm/mach-omap1/board-ams-delta.c

index 3d191fd..1788674 100644 (file)
@@ -750,6 +750,9 @@ static void modem_pm(struct uart_port *port, unsigned int state, unsigned old)
        struct modem_private_data *priv = port->private_data;
        int ret;
 
+       if (!priv)
+               return;
+
        if (IS_ERR(priv->regulator))
                return;