]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
gpiolib: fix invalid pointer access in debugfs
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Mon, 3 Nov 2025 14:11:32 +0000 (15:11 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Nov 2025 20:37:42 +0000 (15:37 -0500)
commit3c91c8f424d3e44c8645ab765a38773e58afb07d
tree0bc54e0bd3ecfe510ac6bc678077bc3f0d761775
parent25decf0469d4c91d90aa2e28d996aed276bfc622
gpiolib: fix invalid pointer access in debugfs

[ Upstream commit 2f6115ad8864cf3f48598f26c74c7c8e5c391919 ]

If the memory allocation in gpiolib_seq_start() fails, the s->private
field remains uninitialized and is later dereferenced without checking
in gpiolib_seq_stop(). Initialize s->private to NULL before calling
kzalloc() and check it before dereferencing it.

Fixes: e348544f7994 ("gpio: protect the list of GPIO devices with SRCU")
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20251103141132.53471-1-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpio/gpiolib.c