dbus: client: notify: free chip and line lists at exit
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Mon, 7 Oct 2024 19:30:23 +0000 (21:30 +0200)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Wed, 9 Oct 2024 07:33:36 +0000 (09:33 +0200)
We don't free the lists storing line and chip objects for the duration
of the program when exiting. Fix it.

Note: these objects need to be kept alive for D-Bus events to work.

Fixes: a5ab76da1e0a ("dbus: add the D-Bus daemon, command-line client and tests")
Link: https://lore.kernel.org/r/20241007-dbus-memory-fixes-v1-2-0d56d1aa032d@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
dbus/client/notify.c

index 6d51a6f65747629035339666a8a48415add42545..800dd243260f668dc01e8688a80747a55fc8e4ee 100644 (file)
@@ -289,6 +289,8 @@ int gpiocli_notify_main(int argc, char **argv)
 
        g_main_loop_run(loop);
 
+       g_list_free_full(data.lines, g_object_unref);
+       g_list_free_full(data.chips, g_object_unref);
        g_bus_unwatch_name(watch_id);
 
        return EXIT_SUCCESS;