Skip to content

Commit

Permalink
openvswitch: Immediately exit on error in ovs_vport_cmd_set().
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jesse Gross committed Jun 14, 2013
1 parent f722406 commit f44f340
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions net/openvswitch/datapath.c
Original file line number Diff line number Diff line change
Expand Up @@ -1812,21 +1812,23 @@ 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) {
err = -ENOMEM;
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_UPCALL_PID])
vport->upcall_portid = nla_get_u32(a[OVS_VPORT_ATTR_UPCALL_PID]);
Expand Down

0 comments on commit f44f340

Please sign in to comment.