net:8021q:Fix error handling in the function vlan_changelink
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 32 lines · Nicholas Krause
This fixes error handling in the function
vlan_changelinkto properly check if its internal calls to the functionsvlan_dev_change_flagsandvlan_dev_set_egress_priorityhave failed by returning a error code which if this occurs return immediately to the caller ofvlan_changelinkto signal to the caller that a failure has occurred when calling this particular function.Signed-off-by Nicholas Krause <[email protected]>--- net/8021q/vlan_netlink.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)net/8021q/vlan_netlink.c +4
-1@@ -93,10 +93,13 @@ static int vlan_changelink(struct net_device *dev,struct ifla_vlan_qos_mapping *m;struct nlattr *attr;int rem; +int err =0 ;if (data[IFLA_VLAN_FLAGS ]) { flags =nla_data (data[IFLA_VLAN_FLAGS ]); -vlan_dev_change_flags (dev, flags->flags, flags->mask); + err =vlan_dev_change_flags (dev, flags->flags, flags->mask); +if (err) + goto err; }if (data[IFLA_VLAN_INGRESS_QOS ]) {nla_for_each_nested (attr, data[IFLA_VLAN_INGRESS_QOS ], rem) {
net/8021q/vlan_netlink.c static int vlan_changelink(struct net_device *dev, · line 115
Quoted 7 lines
net/8021q/vlan_netlink.c +3
-1@@ -107,10 +110,13 @@ static int vlan_changelink(struct net_device *dev,if (data[IFLA_VLAN_EGRESS_QOS ]) {nla_for_each_nested (attr, data[IFLA_VLAN_EGRESS_QOS ], rem) { m =nla_data (attr); -vlan_dev_set_egress_priority (dev, m->from, m->to); + err =vlan_dev_set_egress_priority (dev, m->from, m->to); +if (err) +break ;
The netlink interface is supposed to provide transactional semantics. If you want to handle this case properly, you need to unroll previous configuration changes.
Quoted 11 lines
net/8021q/vlan_netlink.c +2
-1} } -return 0 ; +err: +return err; } static int vlan_newlink(struct net *src_net, struct net_device *dev,Signature · 1 line
2.1.4