From: Jesse Gross Date: Thu, 2 May 2013 17:14:54 +0000 (-0700) Subject: datapath: Immediately exit on error in ovs_vport_cmd_set(). X-Git-Tag: sliver-openvswitch-1.10.90-3~17^2~10 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=17ec1d04252bad77e816ecddd09bbb6db30b3575;p=sliver-openvswitch.git datapath: 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 Acked-by: Pravin B Shelar --- diff --git a/datapath/datapath.c b/datapath/datapath.c index cf901d258..42af31588 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -2105,10 +2105,11 @@ static int ovs_vport_cmd_set(struct sk_buff *skb, struct genl_info *info) if (IS_ERR(vport)) goto exit_unlock; - err = 0; if (a[OVS_VPORT_ATTR_TYPE] && - nla_get_u32(a[OVS_VPORT_ATTR_TYPE]) != vport->ops->type) + nla_get_u32(a[OVS_VPORT_ATTR_TYPE]) != vport->ops->type) { err = -EINVAL; + goto exit_unlock; + } reply = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); if (!reply) { @@ -2116,10 +2117,11 @@ static int ovs_vport_cmd_set(struct sk_buff *skb, struct genl_info *info) goto exit_unlock; } - if (!err && a[OVS_VPORT_ATTR_OPTIONS]) + if (a[OVS_VPORT_ATTR_OPTIONS]) { err = ovs_vport_set_options(vport, a[OVS_VPORT_ATTR_OPTIONS]); - if (err) - goto exit_free; + if (err) + goto exit_free; + } if (a[OVS_VPORT_ATTR_STATS]) ovs_vport_set_stats(vport, nla_data(a[OVS_VPORT_ATTR_STATS]));