]> www.infradead.org Git - users/dwmw2/linux.git/commit
gpio: sim: fix memory corruption when adding named lines and unnamed hogs
authorKent Gibson <warthog618@gmail.com>
Tue, 6 Jun 2023 12:00:34 +0000 (20:00 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 14 Jun 2023 09:17:02 +0000 (11:17 +0200)
commit2a137366586cf97e0d9ce90fc1a9fc67c24f86d3
tree03244d2c267e4ca84fc68b42ad92680f2c9de9a1
parent2ac1d1f54c228ea31e735e5b80605dc5af4773e7
gpio: sim: fix memory corruption when adding named lines and unnamed hogs

[ Upstream commit 95ae9979bfe3174c2ee8d64409c44532f2881907 ]

When constructing the sim, gpio-sim constructs an array of named lines,
sized based on the largest offset of any named line, and then initializes
that array with the names of all lines, including unnamed hogs with higher
offsets.  In doing so it writes NULLs beyond the extent of the array.

Add a check that only named lines are used to initialize the array.

Fixes: cb8c474e79be ("gpio: sim: new testing module")
Signed-off-by: Kent Gibson<warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpio/gpio-sim.c