diff options
author | Johan Hedberg <johan.hedberg@nokia.com> | 2007-08-15 10:00:51 +0000 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@nokia.com> | 2007-08-15 10:00:51 +0000 |
commit | b1cd269c68b76018c2aabd550d37b3b7348e5cd6 (patch) | |
tree | 7e26be1d468f4121c81f1c8f33381f18e90c4b90 | |
parent | a79bcc5733cb5898abb878fb3cfe8ba27fef7bdf (diff) |
Yet another fix (memory leak) to using find_adapter
-rw-r--r-- | audio/device.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/audio/device.c b/audio/device.c index 63ab7778..fe3af8cb 100644 --- a/audio/device.c +++ b/audio/device.c @@ -195,7 +195,6 @@ struct device *device_register(DBusConnection *conn, struct device *dev; bdaddr_t src; int dev_id; - char *adapter_path; if (!conn || !path) return NULL; @@ -205,12 +204,14 @@ struct device *device_register(DBusConnection *conn, if ((dev_id < 0) || (hci_devba(dev_id, &src) < 0)) return NULL; - adapter_path = find_adapter(conn, &src); - if (!adapter_path) - return NULL; - dev = g_new0(struct device, 1); + dev->adapter_path = find_adapter(conn, &src); + if (!dev->adapter_path) { + device_free(dev); + return NULL; + } + if (!dbus_connection_create_object_path(conn, path, dev, device_unregister)) { error("D-Bus failed to register %s path", path); @@ -230,7 +231,6 @@ struct device *device_register(DBusConnection *conn, bacpy(&dev->dst, bda); bacpy(&dev->src, &src); dev->conn = dbus_connection_ref(conn); - dev->adapter_path = adapter_path; return dev; } |