[PATCH libgpiod 1/3] dbus: client: notify: fix reference counting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx>

There's a reference overflow when adding chips to the global list and an
underflow when fetching existing chips from that list in connect_line().
Fix both issues.

Fixes: a5ab76da1e0a ("dbus: add the D-Bus daemon, command-line client and tests")
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx>
---
 dbus/client/notify.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/dbus/client/notify.c b/dbus/client/notify.c
index 5c73343..6d51a6f 100644
--- a/dbus/client/notify.c
+++ b/dbus/client/notify.c
@@ -211,10 +211,10 @@ static void connect_line(gpointer elem, gpointer user_data)
 	if (data->scoped_chip) {
 		if (g_list_length(data->chips) == 0) {
 			chip = gpiodbus_object_get_chip(chip_obj);
-			data->chips = g_list_append(data->chips,
-						    g_object_ref(chip));
+			data->chips = g_list_append(data->chips, chip);
 		} else {
 			chip = g_list_first(data->chips)->data;
+			g_object_ref(chip);
 		}
 	} else {
 		chip = gpiodbus_object_get_chip(chip_obj);

-- 
2.43.0





[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux