All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] serial: 8250_aspeed_vuart: Fix potential NULL dereference in aspeed_vuart_probe
@ 2022-04-04 14:38 ` Miaoqian Lin
  0 siblings, 0 replies; 9+ messages in thread
From: Miaoqian Lin @ 2022-04-04 14:38 UTC (permalink / raw)
  To: linux-aspeed

platform_get_resource() may fail and return NULL, so we should
better check it's return value to avoid a NULL pointer dereference.

Fixes: 54da3e381c2b ("serial: 8250_aspeed_vuart: use UPF_IOREMAP to set up register mapping")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 drivers/tty/serial/8250/8250_aspeed_vuart.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/tty/serial/8250/8250_aspeed_vuart.c b/drivers/tty/serial/8250/8250_aspeed_vuart.c
index 93fe10c680fb..9d2a7856784f 100644
--- a/drivers/tty/serial/8250/8250_aspeed_vuart.c
+++ b/drivers/tty/serial/8250/8250_aspeed_vuart.c
@@ -429,6 +429,8 @@ static int aspeed_vuart_probe(struct platform_device *pdev)
 	timer_setup(&vuart->unthrottle_timer, aspeed_vuart_unthrottle_exp, 0);
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res)
+		return -EINVAL;
 
 	memset(&port, 0, sizeof(port));
 	port.port.private_data = vuart;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-04-04 15:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-04 14:38 [PATCH] serial: 8250_aspeed_vuart: Fix potential NULL dereference in aspeed_vuart_probe Miaoqian Lin
2022-04-04 14:38 ` Miaoqian Lin
2022-04-04 14:38 ` Miaoqian Lin
2022-04-04 14:45 ` Greg Kroah-Hartman
2022-04-04 14:45   ` Greg Kroah-Hartman
2022-04-04 14:45   ` Greg Kroah-Hartman
2022-04-04 15:25   ` Miaoqian Lin
2022-04-04 15:25     ` Miaoqian Lin
2022-04-04 15:25     ` Miaoqian Lin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.