X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fnetifd.git;a=blobdiff_plain;f=ubus.c;h=2b92c780702f966db9b99791fa338d25746cb70c;hp=be9e63221077786867c263587c1f62e7d1d4a515;hb=16e21f6b33c40895cda27af4bc9f3bd0136d2482;hpb=8a671b56edd90d9b19ea4317ce664793ee324cb4 diff --git a/ubus.c b/ubus.c index be9e632..2b92c78 100644 --- a/ubus.c +++ b/ubus.c @@ -25,7 +25,6 @@ static struct ubus_context *ctx = NULL; static struct blob_buf b; -static struct netifd_fd ubus_fd; static const char *ubus_path; /* global object */ @@ -258,8 +257,7 @@ static void netifd_ubus_add_fd(void) { ubus_add_uloop(ctx); - ubus_fd.fd = ctx->sock.fd; - netifd_fd_add(&ubus_fd); + system_fd_set_cloexec(ctx->sock.fd); } static void @@ -283,7 +281,6 @@ netifd_ubus_reconnect_timer(struct uloop_timeout *timeout) static void netifd_ubus_connection_lost(struct ubus_context *ctx) { - netifd_fd_delete(&ubus_fd); netifd_ubus_reconnect_timer(NULL); } @@ -595,8 +592,10 @@ netifd_iface_handle_device(struct ubus_context *ctx, struct ubus_object *obj, device_lock(); dev = device_get(blobmsg_data(tb[DEV_NAME]), add ? 2 : 0); - if (add && !dev) - return UBUS_STATUS_NOT_FOUND; + if (!dev) { + ret = UBUS_STATUS_NOT_FOUND; + goto out; + } if (add) { device_set_present(dev, true); @@ -609,6 +608,7 @@ netifd_iface_handle_device(struct ubus_context *ctx, struct ubus_object *obj, ret = interface_remove_link(iface, dev); } +out: device_unlock(); return ret; @@ -727,8 +727,7 @@ netifd_ubus_add_interface(struct interface *iface) struct ubus_object *obj = &iface->ubus; char *name = NULL; - asprintf(&name, "%s.interface.%s", main_object.name, iface->name); - if (!name) + if (asprintf(&name, "%s.interface.%s", main_object.name, iface->name) == -1) return; obj->name = name;