device: Return an error if netdev_set_powered fails

netdev_set_powered could in theory return an error.  So handle this
case by returning an error from the property set call.
This commit is contained in:
Denis Kenzior 2018-08-17 11:52:47 -05:00
parent eab0731cb1
commit 3a9b1f2e38
1 changed files with 7 additions and 2 deletions

View File

@ -2296,6 +2296,7 @@ static struct l_dbus_message *device_property_set_powered(struct l_dbus *dbus,
struct device *device = user_data;
bool powered;
struct set_generic_cb_data *cb_data;
int r;
if (!l_dbus_message_iter_get_variant(new_value, "b", &powered))
return dbus_error_invalid_args(message);
@ -2312,8 +2313,12 @@ static struct l_dbus_message *device_property_set_powered(struct l_dbus *dbus,
cb_data->message = message;
cb_data->complete = complete;
netdev_set_powered(device->netdev, powered, set_powered_cb, cb_data,
l_free);
r = netdev_set_powered(device->netdev, powered, set_powered_cb,
cb_data, l_free);
if (r < 0) {
l_free(cb_data);
return dbus_error_from_errno(r, message);
}
return NULL;
}