]> www.infradead.org Git - users/jedix/linux-maple.git/commit
gpio: virtuser: fix missing lookup table cleanups
authorKoichiro Den <koichiro.den@canonical.com>
Fri, 3 Jan 2025 14:18:26 +0000 (23:18 +0900)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Fri, 3 Jan 2025 16:15:03 +0000 (17:15 +0100)
commita619cba8c69c434258ff4101d463322cd63e1bdc
tree738dc2a7f6eb6ef7e699fb4c6feb696d89df8da5
parentfc033cf25e612e840e545f8d5ad2edd6ba613ed5
gpio: virtuser: fix missing lookup table cleanups

When a virtuser device is created via configfs and the probe fails due
to an incorrect lookup table, the table is not removed. This prevents
subsequent probe attempts from succeeding, even if the issue is
corrected, unless the device is released. Additionally, cleanup is also
needed in the less likely case of platform_device_register_full()
failure.

Besides, a consistent memory leak in lookup_table->dev_id was spotted
using kmemleak by toggling the live state between 0 and 1 with a correct
lookup table.

Introduce gpio_virtuser_remove_lookup_table() as the counterpart to the
existing gpio_virtuser_make_lookup_table() and call it from all
necessary points to ensure proper cleanup.

Fixes: 91581c4b3f29 ("gpio: virtuser: new virtual testing driver for the GPIO API")
Signed-off-by: Koichiro Den <koichiro.den@canonical.com>
Link: https://lore.kernel.org/r/20250103141829.430662-2-koichiro.den@canonical.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
drivers/gpio/gpio-virtuser.c