Re: [PATCH] gpiolib: fix lookup table matching

From: Val Packett
Date: Thu Jan 08 2026 - 23:42:57 EST


On 1/8/26 7:23 AM, Bartosz Golaszewski wrote:

If on any iteration in gpiod_find(), gpio_desc_table_match() returns
NULL (which is normal and expected), we never reinitialize desc back to
ERR_PTR(-ENOENT) and if we don't find a match later on, we will return
NULL causing a NULL-pointer dereference in users not expecting it. Don't
initialize desc, but return ERR_PTR(-ENOENT) explicitly at the end of
the function.

Fixes: 9700b0fccf38 ("gpiolib: allow multiple lookup tables per consumer")
Reported-by: Marek Szyprowski <m.szyprowski@xxxxxxxxxxx>
Closes: https://lore.kernel.org/all/00107523-7737-4b92-a785-14ce4e93b8cb@xxxxxxxxxxx/
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>


Tested-by: Val Packett <val@xxxxxxxxxxxx>

This also fixes things on Qualcomm x1e laptops (same NULL deref logged from snd_soc_wcd938x wcd938x_probe, but as a consequence the display&gpu subsystem also wouldn't work)