[PATCH BlueZ v0 2/2] heartrate: Fix D-Bus registration error case

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

 



From: Mikel Astiz <mikel.astiz@xxxxxxxxxxxx>

If g_dbus_register_interface() fails, the struct heartrate_adapter
memory will be freed and therefore the heartrate_adapters list cannot
contain such an invalid pointer.
---
 profiles/heartrate/heartrate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/profiles/heartrate/heartrate.c b/profiles/heartrate/heartrate.c
index 8de81bb..34ec9bc 100644
--- a/profiles/heartrate/heartrate.c
+++ b/profiles/heartrate/heartrate.c
@@ -730,8 +730,6 @@ static int heartrate_adapter_register(struct btd_adapter *adapter)
 	hradapter = g_new0(struct heartrate_adapter, 1);
 	hradapter->adapter = adapter;
 
-	heartrate_adapters = g_slist_prepend(heartrate_adapters, hradapter);
-
 	if (!g_dbus_register_interface(btd_get_dbus_connection(),
 						adapter_get_path(adapter),
 						HEART_RATE_MANAGER_INTERFACE,
@@ -744,6 +742,8 @@ static int heartrate_adapter_register(struct btd_adapter *adapter)
 		return -EIO;
 	}
 
+	heartrate_adapters = g_slist_prepend(heartrate_adapters, hradapter);
+
 	return 0;
 }
 
-- 
1.8.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux