From: Hans Dedecker Date: Wed, 18 Jun 2014 05:55:47 +0000 (+0000) Subject: netifd: Check device_claim return code in all cases X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=5d655d1d3f6880b53ea5bafda159c02da038548f;p=project%2Fnetifd.git netifd: Check device_claim return code in all cases Fixes observed issue a tunnel interface is reported as up although device_claim failed Signed-off-by: Hans Dedecker --- diff --git a/interface.c b/interface.c index 6ca1d0d..b0fe9de 100644 --- a/interface.c +++ b/interface.c @@ -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); diff --git a/proto-shell.c b/proto-shell.c index c4039ed..9fad3a0 100644 --- a/proto-shell.c +++ b/proto-shell.c @@ -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 28e561b..28b1441 100644 --- 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);