commit d66dcc94127f2a4dd901e9e0c78319e90e7b8214
parent 0b65fe3a95ed2501db946c7b1eea2f16f7e69699
Author: Diego Santa Cruz <Diego.SantaCruz@spinetix.com>
Date: Tue, 7 Apr 2020 23:33:46 +0200
adhoc: fix bogus Failed error and segfault on stop
The netdev_leave_adhoc() returns a negative errno on errors and zero
on success, but adhoc_dbus_stop() assumed the inverse when checking for
an error.
Also, the DBus message was not being referenced in adhoc->pending and
then adhoc_leave_cb() segfaulted attempting to dereference it.
Diffstat:
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/adhoc.c b/src/adhoc.c
@@ -576,9 +576,11 @@ static struct l_dbus_message *adhoc_dbus_stop(struct l_dbus *dbus,
if (!adhoc->started)
return l_dbus_message_new_method_return(message);
- if (!netdev_leave_adhoc(adhoc->netdev, adhoc_leave_cb, adhoc))
+ if (netdev_leave_adhoc(adhoc->netdev, adhoc_leave_cb, adhoc))
return dbus_error_failed(message);
+ adhoc->pending = l_dbus_message_ref(message);
+
return NULL;
}