fix removal of unknown device
authorNathan Hintz <nlhintz@hotmail.com>
Sun, 6 Jan 2013 02:41:45 +0000 (18:41 -0800)
committerFelix Fietkau <nbd@openwrt.org>
Sun, 6 Jan 2013 03:09:24 +0000 (04:09 +0100)
Netifd will crash if an attempt is made to remove a device that is not
known to netifd.  For instance:

  ubus call network.interface.lan remove_device "{ \"name\": \"xxx\" }"

Signed-off-by: Nathan Hintz <nlhintz@hotmail.com>
ubus.c

diff --git a/ubus.c b/ubus.c
index d6d41889ef2a501715d506aea19281f7c49d44b7..2b92c780702f966db9b99791fa338d25746cb70c 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;
        }