aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiego Santa Cruz <Diego.SantaCruz@spinetix.com>2020-04-07 23:33:46 +0200
committerDenis Kenzior <denkenz@gmail.com>2020-04-06 17:17:19 -0500
commitd66dcc94127f2a4dd901e9e0c78319e90e7b8214 (patch)
tree27697573a545732e3665ec500f90e550ccc4e016
parent0b65fe3a95ed2501db946c7b1eea2f16f7e69699 (diff)
downloadiwd-d66dcc94127f2a4dd901e9e0c78319e90e7b8214.tar.gz
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.
-rw-r--r--src/adhoc.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/adhoc.c b/src/adhoc.c
index a8ff8c3a0..328433ca8 100644
--- 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;
}