From: Simon Horman <simon.horman@netronome.com>
To: John Fastabend <john.fastabend@gmail.com>
Cc: netdev@vger.kernel.org, Simon Horman <simon.horman@netronome.com>
Subject: [PATCH/RFC rocker-net-next 4/6] net: flow: free action args
Date: Mon, 5 Jan 2015 15:50:08 +0900 [thread overview]
Message-ID: <1420440610-20621-5-git-send-email-simon.horman@netronome.com> (raw)
In-Reply-To: <1420440610-20621-1-git-send-email-simon.horman@netronome.com>
Free the args of an action along with the action itself to avoid leaking
memory.
Signed-off-by: Simon Horman <simon.horman@netronome.com>
---
net/core/flow_table.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/net/core/flow_table.c b/net/core/flow_table.c
index c734a9d..1a32a72 100644
--- a/net/core/flow_table.c
+++ b/net/core/flow_table.c
@@ -1050,6 +1050,18 @@ static int net_flow_get_field(struct net_flow_field_ref *field,
return 0;
}
+static void net_flow_free_actions(struct net_flow_action *actions)
+{
+ int i;
+
+ if (!actions)
+ return;
+
+ for (i = 0; actions[i].uid; i++)
+ kfree(actions[i].args);
+ kfree(actions);
+}
+
static int net_flow_get_action(struct net_flow_action *a, struct nlattr *attr)
{
struct nlattr *act[NET_FLOW_ACTION_ATTR_MAX+1];
@@ -1168,7 +1180,7 @@ static int net_flow_get_flow(struct net_flow_flow *flow, struct nlattr *attr)
err = net_flow_get_action(&flow->actions[count], attr2);
if (err) {
kfree(flow->matches);
- kfree(flow->actions);
+ net_flow_free_actions(flow->actions);
return err;
}
count++;
@@ -1251,7 +1263,7 @@ static int net_flow_table_cmd_flows(struct sk_buff *recv_skb,
/* Cleanup flow */
kfree(this.matches);
- kfree(this.actions);
+ net_flow_free_actions(this.actions);
if (err && err_handle == NET_FLOW_FLOWS_ERROR_ABORT)
goto out;
--
2.1.3
next prev parent reply other threads:[~2015-01-05 6:50 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-05 6:50 [PATCH/RFC rocker-net-next 0/6] net: flow: Minor fixes and cleanups Simon Horman
2015-01-05 6:50 ` [PATCH/RFC rocker-net-next 1/6] net: flow: Cancel innermost nested attribute first Simon Horman
2015-01-05 21:17 ` David Miller
2015-01-05 22:01 ` Thomas Graf
2015-01-05 22:10 ` David Miller
2015-01-06 1:03 ` Simon Horman
2015-01-05 6:50 ` [PATCH/RFC rocker-net-next 2/6] net: flow: Handle error when putting a field while putting a flow Simon Horman
2015-01-05 17:28 ` John Fastabend
2015-01-06 1:04 ` Simon Horman
2015-01-05 6:50 ` [PATCH/RFC rocker-net-next 3/6] net: flow: Remove unnecessary zero-header check when " Simon Horman
2015-01-05 6:50 ` Simon Horman [this message]
2015-01-05 6:50 ` [PATCH/RFC rocker-net-next 5/6] net: flow: Return more fine-grained error when handing flows commands Simon Horman
2015-01-05 6:50 ` [PATCH/RFC rocker-net-next 6/6] net: flow: Limit checking of ndo_flow_{set,del}_flows Simon Horman
2015-01-05 17:32 ` John Fastabend
2015-01-06 1:07 ` Simon Horman
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=1420440610-20621-5-git-send-email-simon.horman@netronome.com \
--to=simon.horman@netronome.com \
--cc=john.fastabend@gmail.com \
--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).