aboutsummaryrefslogtreecommitdiffstats
path: root/net/openvswitch/datapath.c
diff options
context:
space:
mode:
authorJesse Gross <jesse@nicira.com>2013-05-13 11:15:26 -0400
committerJesse Gross <jesse@nicira.com>2013-06-14 18:09:09 -0400
commitf44f340883388b57fe03edfb0982e038e57a992c (patch)
treedc09348aa79668d45e3e48faea332feebae9bdd8 /net/openvswitch/datapath.c
parentf722406faae2d073cc1d01063d1123c35425939e (diff)
openvswitch: Immediately exit on error in ovs_vport_cmd_set().
It is an error to try to change the type of a vport using the set command. However, while we check that this is an error, we still proceed to allocate memory which then gets freed immediately. This stops processing after noticing the error, which does not actually fix a bug but is more correct. Signed-off-by: Jesse Gross <jesse@nicira.com>
Diffstat (limited to 'net/openvswitch/datapath.c')
-rw-r--r--net/openvswitch/datapath.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index d12d6b8b5e8b..748aa97cbfb2 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -1812,10 +1812,11 @@ static int ovs_vport_cmd_set(struct sk_buff *skb, struct genl_info *info)
1812 if (IS_ERR(vport)) 1812 if (IS_ERR(vport))
1813 goto exit_unlock; 1813 goto exit_unlock;
1814 1814
1815 err = 0;
1816 if (a[OVS_VPORT_ATTR_TYPE] && 1815 if (a[OVS_VPORT_ATTR_TYPE] &&
1817 nla_get_u32(a[OVS_VPORT_ATTR_TYPE]) != vport->ops->type) 1816 nla_get_u32(a[OVS_VPORT_ATTR_TYPE]) != vport->ops->type) {
1818 err = -EINVAL; 1817 err = -EINVAL;
1818 goto exit_unlock;
1819 }
1819 1820
1820 reply = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); 1821 reply = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
1821 if (!reply) { 1822 if (!reply) {
@@ -1823,10 +1824,11 @@ static int ovs_vport_cmd_set(struct sk_buff *skb, struct genl_info *info)
1823 goto exit_unlock; 1824 goto exit_unlock;
1824 } 1825 }
1825 1826
1826 if (!err && a[OVS_VPORT_ATTR_OPTIONS]) 1827 if (a[OVS_VPORT_ATTR_OPTIONS]) {
1827 err = ovs_vport_set_options(vport, a[OVS_VPORT_ATTR_OPTIONS]); 1828 err = ovs_vport_set_options(vport, a[OVS_VPORT_ATTR_OPTIONS]);
1828 if (err) 1829 if (err)
1829 goto exit_free; 1830 goto exit_free;
1831 }
1830 1832
1831 if (a[OVS_VPORT_ATTR_UPCALL_PID]) 1833 if (a[OVS_VPORT_ATTR_UPCALL_PID])
1832 vport->upcall_portid = nla_get_u32(a[OVS_VPORT_ATTR_UPCALL_PID]); 1834 vport->upcall_portid = nla_get_u32(a[OVS_VPORT_ATTR_UPCALL_PID]);