mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] tty: serial: pch_uart: add check for pci_get_slot()
@ 2026-06-23 14:05 Haoxiang Li
  2026-06-23 16:03 ` Andy Shevchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Haoxiang Li @ 2026-06-23 14:05 UTC (permalink / raw)
  To: gregkh, jirislaby, andriy.shevchenko, fourier.thomas, 2426767509, kees
  Cc: linux-kernel, linux-serial, Haoxiang Li, stable

Add check for pci_get_slot() to prevent a potetial
null pointer dereference in pch_request_dma().

Fixes: 8368d6a2b739 ("pch_uart: don't hardcode PCI slot to get DMA device")
Cc: stable@vger.kernel.org
Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
---
 drivers/tty/serial/pch_uart.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c
index ba1fcd663fe2..6c9e596a14e7 100644
--- a/drivers/tty/serial/pch_uart.c
+++ b/drivers/tty/serial/pch_uart.c
@@ -678,6 +678,11 @@ static void pch_request_dma(struct uart_port *port)
 	/* Get DMA's dev information */
 	dma_dev = pci_get_slot(priv->pdev->bus,
 			PCI_DEVFN(PCI_SLOT(priv->pdev->devfn), 0));
+	if (!dma_dev) {
+		dev_err(priv->port.dev, "%s: failed to get DMA device\n",
+			__func__);
+		return;
+	}
 
 	/* Set Tx DMA */
 	param = &priv->param_tx;
-- 
2.25.1


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

end of thread, other threads:[~2026-06-23 16:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-23 14:05 [PATCH] tty: serial: pch_uart: add check for pci_get_slot() Haoxiang Li
2026-06-23 16:03 ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®