netifd: Check device_claim return code in all cases
authorHans Dedecker <dedeckeh@gmail.com>
Wed, 18 Jun 2014 05:55:47 +0000 (05:55 +0000)
committerSteven Barth <steven@midlink.org>
Wed, 18 Jun 2014 11:01:32 +0000 (13:01 +0200)
Fixes observed issue a tunnel interface is reported as up although device_claim failed

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
interface.c
proto-shell.c
vlan.c

index 6ca1d0da0be7cd61ec835a8e691a83a8a02490c2..b0fe9deee601eee0dc2bf8b82dba2d9bec89b52c 100644 (file)
@@ -766,8 +766,10 @@ interface_set_l3_dev(struct interface *iface, struct device *dev)
        device_add_user(&iface->l3_dev, dev);
 
        if (dev) {
-               if (claimed)
-                       device_claim(&iface->l3_dev);
+               if (claimed) {
+                       if (device_claim(&iface->l3_dev) < 0)
+                               return;
+               }
                interface_ip_set_enabled(&iface->config_ip, enabled);
        }
 }
@@ -787,8 +789,10 @@ interface_set_main_dev(struct interface *iface, struct device *dev)
                return;
        }
 
-       if (claimed)
-               device_claim(&iface->l3_dev);
+       if (claimed) {
+               if (device_claim(&iface->l3_dev) < 0)
+                       return;
+       }
 
        if (!iface->l3_dev.dev)
                interface_set_l3_dev(iface, dev);
index c4039ed6a486169f86931d8d075d9e037b2be566..9fad3a0a581f038c703da42348084084d1110198 100644 (file)
@@ -463,7 +463,9 @@ proto_shell_update_link(struct proto_shell_state *state, struct blob_attr *data,
                        return UBUS_STATUS_INVALID_ARGUMENT;
 
                interface_set_l3_dev(iface, dev);
-               device_claim(&iface->l3_dev);
+               if (device_claim(&iface->l3_dev) < 0)
+                       return UBUS_STATUS_UNKNOWN_ERROR;
+
                device_set_present(dev, true);
 
                interface_update_start(iface);
diff --git a/vlan.c b/vlan.c
index 28e561b61dd2aa5523ecff3466bb21e7ed022f34..28b14417819b9c2a37ca84e273b5a36497379d31 100644 (file)
--- a/vlan.c
+++ b/vlan.c
@@ -50,7 +50,7 @@ static int vlan_set_device_state(struct device *dev, bool up)
        }
 
        ret = device_claim(&vldev->dep);
-       if (ret)
+       if (ret < 0)
                return ret;
 
        system_vlan_add(vldev->dep.dev, vldev->id);