diff options
-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; } |