Skip to content

Commit 95637d9

Browse files
apconolekuba-moo
authored andcommitted
net: openvswitch: release vport resources on failure
A recent commit introducing upcall packet accounting failed to properly release the vport object when the per-cpu stats struct couldn't be allocated. This can cause dangling pointers to dp objects long after they've been released. Cc: wangchuanlei <[email protected]> Fixes: 1933ea3 ("net: openvswitch: Add support to count upcall packets") Reported-by: [email protected] Signed-off-by: Aaron Conole <[email protected]> Acked-by: Eelco Chaudron <[email protected]> Reviewed-by: Michal Swiatkowski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent f2575c8 commit 95637d9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

net/openvswitch/datapath.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1861,7 +1861,7 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)
18611861
vport->upcall_stats = netdev_alloc_pcpu_stats(struct vport_upcall_stats_percpu);
18621862
if (!vport->upcall_stats) {
18631863
err = -ENOMEM;
1864-
goto err_destroy_portids;
1864+
goto err_destroy_vport;
18651865
}
18661866

18671867
err = ovs_dp_cmd_fill_info(dp, reply, info->snd_portid,
@@ -1876,6 +1876,8 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)
18761876
ovs_notify(&dp_datapath_genl_family, reply, info);
18771877
return 0;
18781878

1879+
err_destroy_vport:
1880+
ovs_dp_detach_port(vport);
18791881
err_destroy_portids:
18801882
kfree(rcu_dereference_raw(dp->upcall_portids));
18811883
err_unlock_and_destroy_meters:
@@ -2323,7 +2325,7 @@ static int ovs_vport_cmd_new(struct sk_buff *skb, struct genl_info *info)
23232325
vport->upcall_stats = netdev_alloc_pcpu_stats(struct vport_upcall_stats_percpu);
23242326
if (!vport->upcall_stats) {
23252327
err = -ENOMEM;
2326-
goto exit_unlock_free;
2328+
goto exit_unlock_free_vport;
23272329
}
23282330

23292331
err = ovs_vport_cmd_fill_info(vport, reply, genl_info_net(info),
@@ -2343,6 +2345,8 @@ static int ovs_vport_cmd_new(struct sk_buff *skb, struct genl_info *info)
23432345
ovs_notify(&dp_vport_genl_family, reply, info);
23442346
return 0;
23452347

2348+
exit_unlock_free_vport:
2349+
ovs_dp_detach_port(vport);
23462350
exit_unlock_free:
23472351
ovs_unlock();
23482352
kfree_skb(reply);

0 commit comments

Comments
 (0)