netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jesse Gross <jesse@nicira.com>
To: David Miller <davem@davemloft.net>
Cc: netdev <netdev@vger.kernel.org>,
	dev@openvswitch.org, Jesse Gross <jesse@nicira.com>
Subject: [PATCH net-next 1/8] openvswitch: Immediately exit on error in ovs_vport_cmd_set().
Date: Fri, 14 Jun 2013 15:28:50 -0700	[thread overview]
Message-ID: <1371248937-35614-2-git-send-email-jesse@nicira.com> (raw)
In-Reply-To: <1371248937-35614-1-git-send-email-jesse@nicira.com>

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>
---
 net/openvswitch/datapath.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index d12d6b8..748aa97 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)
 	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) {
@@ -1823,10 +1824,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_UPCALL_PID])
 		vport->upcall_portid = nla_get_u32(a[OVS_VPORT_ATTR_UPCALL_PID]);
-- 
1.8.1.2

  reply	other threads:[~2013-06-14 22:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-14 22:28 [GIT net-next] Open vSwitch Jesse Gross
2013-06-14 22:28 ` Jesse Gross [this message]
2013-06-14 22:28 ` [PATCH net-next 2/8] openvswitch: Remove unused get_config vport op Jesse Gross
2013-06-14 22:28 ` [PATCH net-next 3/8] openvswitch: Unify vport error stats handling Jesse Gross
2013-06-14 22:28 ` [PATCH net-next 4/8] openvswitch: fix variable names in comment Jesse Gross
2013-06-14 22:28 ` [PATCH net-next 6/8] openvswitch: Fix struct comment Jesse Gross
     [not found] ` <1371248937-35614-1-git-send-email-jesse-l0M0P4e3n4LQT0dZR+AlfA@public.gmane.org>
2013-06-14 22:28   ` [PATCH net-next 5/8] openvswitch: Fix misspellings in comments and docs Jesse Gross
2013-06-14 22:28   ` [PATCH net-next 7/8] openvswitch: make skb->csum consistent with rest of networking stack Jesse Gross
2013-06-14 22:28   ` [PATCH net-next 8/8] openvswitch: Simplify interface ovs_flow_metadata_from_nlattrs() Jesse Gross
2013-06-14 22:34 ` [GIT net-next] Open vSwitch David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1371248937-35614-2-git-send-email-jesse@nicira.com \
    --to=jesse@nicira.com \
    --cc=davem@davemloft.net \
    --cc=dev@openvswitch.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).