Skip to contentSkip to conversation

tty: serial: fsl_lpuart: fix crash in lpuart_uport_is_active

PATCH New Sherry Sun 1 participant 1 message Mar 23, 2023 TTY layer and serial drivers

lore
Share & tools
lore

Sherry Sun

author
#0 lore raw

PATCH 1/1 tty: serial: fsl_lpuart: fix crash in lpuart_uport_is_active

For serdev framework, tty->dev is a NULL pointer, lpuart_uport_is_active calling device_may_wakeup() may cause kernel NULL pointer crash, so here add the NULL pointer check before using it.

Fixes 4f5cb8c5e915 ("tty: serial: fsl_lpuart: enable wakeup source for lpuart")
---
 drivers/tty/serial/fsl_lpuart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/fsl_lpuart.c +1 -1
index 3281e81e1723..8daac87d063c 100644
@@ -3022,7 +3022,7 @@ static bool lpuart_uport_is_active(struct lpuart_port *sport)
 	tty = tty_port_tty_get(port);
 	if (tty) {
 		tty_dev = tty->dev;
-		may_wake = device_may_wakeup(tty_dev);
+		may_wake = tty_dev && device_may_wakeup(tty_dev);
 		tty_kref_put(tty);
 	}
 
Signature · 1 line
2.17.1