diff mbox series

ARM: OMAP1: ams-delta: Fix possible use of uninitialized field

Message ID 20181107213031.21650-1-jmkrzyszt@gmail.com (mailing list archive)
State New, archived
Headers show
Series ARM: OMAP1: ams-delta: Fix possible use of uninitialized field | expand

Commit Message

Janusz Krzysztofik Nov. 7, 2018, 9:30 p.m. UTC
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>
---
 arch/arm/mach-omap1/board-ams-delta.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Tony Lindgren Nov. 8, 2018, 5:25 p.m. UTC | #1
* Janusz Krzysztofik <jmkrzyszt@gmail.com> [181107 13:28]:
> 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().

Applying into omap-for-v4.20/fixes thanks.

Tony
diff mbox series

Patch

diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
index 1947bc63074e..17e0b386e1b2 100644
--- a/arch/arm/mach-omap1/board-ams-delta.c
+++ b/arch/arm/mach-omap1/board-ams-delta.c
@@ -764,6 +764,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;