Re: [PATCH] input: mtk-pmic-keys: Fix potential NULL pointer dereference in probe()

From: Dmitry Torokhov
Date: Tue Dec 09 2025 - 23:48:37 EST


Hi Haotian,

On Wed, Dec 10, 2025 at 11:00:13AM +0800, Haotian Zhang wrote:
> of_match_device() may return NULL when the device node
> does not match any entry in the driver's match table.
> The current code dereferences of_id->data unconditionally,
> which can lead to a NULL pointer dereference.

How are we getting into probe() without matching compatible?

We already had a discussion about this in [1] and patched the MFD
portion to not use generic driver name when instantiating the keypad
sub-device.

[1] http://lore.kernel.org/r/20250630-mtk-pmic-keys-fix-crash-v1-1-e47351fa9d1f@xxxxxxxxxxxxx

Thanks.

--
Dmitry