[ovs-dev] [PATCH 10/10] datapath: Use local variable for freeing on flow put error.

Jesse Gross jesse at nicira.com
Wed Dec 29 04:50:48 UTC 2010


If inserting a flow failed and we need to free the actions, we
currently directly free them from the flow struct.  This is fine
but it makes sparse complain about directly accessing an RCU
protected field.  We could insert some casts to avoid this but
it's cleaner to just free the data from the local variable
instead.

Found with sparse.

Signed-off-by: Jesse Gross <jesse at nicira.com>
---
 datapath/datapath.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/datapath/datapath.c b/datapath/datapath.c
index d606913..64ec23c 100644
--- a/datapath/datapath.c
+++ b/datapath/datapath.c
@@ -823,6 +823,7 @@ static int do_put_flow(struct datapath *dp, struct odp_flow_put *uf,
 	struct tbl_node *flow_node;
 	struct sw_flow *flow;
 	struct tbl *table;
+	struct sw_flow_actions *acts = NULL;
 	int error;
 	u32 hash;
 
@@ -831,8 +832,6 @@ static int do_put_flow(struct datapath *dp, struct odp_flow_put *uf,
 	flow_node = tbl_lookup(table, &uf->flow.key, hash, flow_cmp);
 	if (!flow_node) {
 		/* No such flow. */
-		struct sw_flow_actions *acts;
-
 		error = -ENOENT;
 		if (!(uf->flags & ODPPF_CREATE))
 			goto error;
@@ -906,7 +905,7 @@ static int do_put_flow(struct datapath *dp, struct odp_flow_put *uf,
 	return 0;
 
 error_free_flow_acts:
-	kfree(flow->sf_acts);
+	kfree(acts);
 error_free_flow:
 	flow->sf_acts = NULL;
 	flow_put(flow);
-- 
1.7.1





More information about the dev mailing list