summaryrefslogtreecommitdiff
path: root/drivers/gpio/gpiolib-shared.c
diff options
context:
space:
mode:
authorBartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>2025-12-06 12:53:53 +0100
committerBartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>2025-12-09 07:16:45 +0100
commite2c4175b8d3b3ea65fc3801c190bd93fe8b7a7a9 (patch)
tree37da4f50af971ee8ac3efc6676ec0d7fba54e853 /drivers/gpio/gpiolib-shared.c
parent9e7a40a2841483d7bf51b8d9a5e1f0633a5c7a26 (diff)
gpio: shared: fix NULL-pointer dereference in teardown path
We need to actually store the address of the GPIO lookup table in the reference struct before we try to free it or - worse - dereference its members. Fixes: a060b8c511ab ("gpiolib: implement low-level, shared GPIO support") Link: https://lore.kernel.org/r/20251206-gpio-shared-teardown-fixes-v1-1-35ac458cfce1@oss.qualcomm.com Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Diffstat (limited to 'drivers/gpio/gpiolib-shared.c')
-rw-r--r--drivers/gpio/gpiolib-shared.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/gpio/gpiolib-shared.c b/drivers/gpio/gpiolib-shared.c
index 5d15675d61ea..17da15c1075f 100644
--- a/drivers/gpio/gpiolib-shared.c
+++ b/drivers/gpio/gpiolib-shared.c
@@ -399,7 +399,8 @@ int gpio_shared_add_proxy_lookup(struct device *consumer, unsigned long lflags)
lookup->table[0] = GPIO_LOOKUP(no_free_ptr(key), 0,
ref->con_id, lflags);
- gpiod_add_lookup_table(no_free_ptr(lookup));
+ ref->lookup = no_free_ptr(lookup);
+ gpiod_add_lookup_table(ref->lookup);
return 0;
}