Skip to content

Commit

Permalink
datapath: fix a memory leak
Browse files Browse the repository at this point in the history
The user_skb maybe be leaked if the operation on it failed and codes
skipped into the label "out:" without calling genlmsg_unicast.

Cc: Pravin Shelar <pshelar@nicira.com>
Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
  • Loading branch information
Li RongQing authored and Pravin B Shelar committed Sep 2, 2014
1 parent b1bf47f commit 82706a6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion datapath/datapath.c
Expand Up @@ -394,7 +394,7 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb,
{
struct ovs_header *upcall;
struct sk_buff *nskb = NULL;
struct sk_buff *user_skb; /* to be queued to userspace */
struct sk_buff *user_skb = NULL; /* to be queued to userspace */
struct sw_flow_key *pkt_key = OVS_CB(skb)->pkt_key;
struct nlattr *nla;
struct genl_info info = {
Expand Down Expand Up @@ -496,9 +496,12 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb,
((struct nlmsghdr *) user_skb->data)->nlmsg_len = user_skb->len;

err = genlmsg_unicast(ovs_dp_get_net(dp), user_skb, upcall_info->portid);
user_skb = NULL;
out:
if (err)
skb_tx_error(skb);

kfree_skb(user_skb);
kfree_skb(nskb);
return err;
}
Expand Down

0 comments on commit 82706a6

Please sign in to comment.