Skip to content

Commit

Permalink
net: openvswitch: fix possible memory leak in ovs_meter_cmd_set()
Browse files Browse the repository at this point in the history
old_meter needs to be free after it is detached regardless of whether
the new meter is successfully attached.

Fixes: c7c4c44 ("net: openvswitch: expand the meters supported number")
Signed-off-by: Hangyu Hua <[email protected]>
Acked-by: Eelco Chaudron <[email protected]>
Reviewed-by: Simon Horman <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
HBh25Y authored and davem330 committed Feb 13, 2023
1 parent 2f47965 commit 2fa28f5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion net/openvswitch/meter.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ static int ovs_meter_cmd_set(struct sk_buff *skb, struct genl_info *info)

err = attach_meter(meter_tbl, meter);
if (err)
goto exit_unlock;
goto exit_free_old_meter;

ovs_unlock();

Expand All @@ -472,6 +472,8 @@ static int ovs_meter_cmd_set(struct sk_buff *skb, struct genl_info *info)
genlmsg_end(reply, ovs_reply_header);
return genlmsg_reply(reply, info);

exit_free_old_meter:
ovs_meter_free(old_meter);
exit_unlock:
ovs_unlock();
nlmsg_free(reply);
Expand Down

0 comments on commit 2fa28f5

Please sign in to comment.