fix removal of unknown device
[project/netifd.git] / ubus.c
diff --git a/ubus.c b/ubus.c
index 7b85930..2b92c78 100644 (file)
--- a/ubus.c
+++ b/ubus.c
@@ -592,7 +592,7 @@ 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) {
+       if (!dev) {
                ret = UBUS_STATUS_NOT_FOUND;
                goto out;
        }
@@ -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;