Skip to content

Commit 600dcd5

Browse files
Jiangshan Yigregkh
authored andcommitted
serial: 8250_mid: Fix NULL function pointer dereference on DNV/ICX-D/SNR platforms
commit 7fb13fd upstream. Commit b1b4efe ("serial: 8250_mid: Disable DMA for selected platforms") replaced the dnv_board setup and exit callbacks with PTR_IF(false, ...), which evaluates to NULL. However, the three call sites in mid8250_probe() and mid8250_remove() unconditionally dereference these function pointers without NULL checks, causing a NULL pointer dereference (kernel oops) on any Denverton (DNV), Ice Lake Xeon D (ICX-D/CDF), or Snowridge (SNR) platform. Fix this by adding the missing NULL checks before calling the setup and exit callbacks. Fixes: b1b4efe ("serial: 8250_mid: Disable DMA for selected platforms") Cc: stable <stable@kernel.org> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Jiangshan Yi <yijiangshan@kylinos.cn> Link: https://patch.msgid.link/20260715073546.1875083-1-yijiangshan@kylinos.cn Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 06f4fc7 commit 600dcd5

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

drivers/tty/serial/8250/8250_mid.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,11 @@ static int mid8250_probe(struct pci_dev *pdev, const struct pci_device_id *id)
318318
if (!uart.port.membase)
319319
return -ENOMEM;
320320

321-
ret = mid->board->setup(mid, &uart.port);
322-
if (ret)
323-
return ret;
321+
if (mid->board->setup) {
322+
ret = mid->board->setup(mid, &uart.port);
323+
if (ret)
324+
return ret;
325+
}
324326

325327
ret = mid8250_dma_setup(mid, &uart);
326328
if (ret)
@@ -336,7 +338,8 @@ static int mid8250_probe(struct pci_dev *pdev, const struct pci_device_id *id)
336338
return 0;
337339

338340
err:
339-
mid->board->exit(mid);
341+
if (mid->board->exit)
342+
mid->board->exit(mid);
340343
return ret;
341344
}
342345

@@ -346,7 +349,8 @@ static void mid8250_remove(struct pci_dev *pdev)
346349

347350
serial8250_unregister_port(mid->line);
348351

349-
mid->board->exit(mid);
352+
if (mid->board->exit)
353+
mid->board->exit(mid);
350354
}
351355

352356
static const struct mid8250_board pnw_board = {

0 commit comments

Comments
 (0)