Re: [PATCH] serial: 8250_mid: Fix NULL function pointer dereference on DNV/ICX-D/SNR platforms

From: Andy Shevchenko

Date: Wed Jul 15 2026 - 02:10:39 EST


On Wed, Jul 15, 2026 at 11:03:36AM +0800, Jiangshan Yi wrote:
> Commit b1b4efea05a5 ("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.

Oh, thanks!
Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
but I have a nit-pick below.

> Fixes: b1b4efea05a5 ("serial: 8250_mid: Disable DMA for selected platforms")
> Cc: stable@xxxxxxxxxx

> Cc: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
> Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

These two Cc may be moved either to --to option of `git format-patch` or after
the cutter '---' line to avoid unneeded noise in the commit message.

...

> - ret = mid->board->setup(mid, &uart.port);
> + ret = mid->board->setup ? mid->board->setup(mid, &uart.port) : 0;
> if (ret)
> return ret;

Likewise the rest, this can be also wrapped to the if-condition:

if (mid->board->setup) {
ret = mid->board->setup(mid, &uart.port);
if (ret)
return ret;
}

--
With Best Regards,
Andy Shevchenko