Skip to content

Commit 2fa28f5

Browse files
HBh25Ydavem330
authored andcommitted
net: openvswitch: fix possible memory leak in ovs_meter_cmd_set()
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]>
1 parent 2f47965 commit 2fa28f5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

net/openvswitch/meter.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ static int ovs_meter_cmd_set(struct sk_buff *skb, struct genl_info *info)
449449

450450
err = attach_meter(meter_tbl, meter);
451451
if (err)
452-
goto exit_unlock;
452+
goto exit_free_old_meter;
453453

454454
ovs_unlock();
455455

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

475+
exit_free_old_meter:
476+
ovs_meter_free(old_meter);
475477
exit_unlock:
476478
ovs_unlock();
477479
nlmsg_free(reply);

0 commit comments

Comments
 (0)