Skip to content

Commit 988b7c8

Browse files
committed
net: openvswitch: release vport resources on failure
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2163678 Upstream Status: linux.git commit 95637d9 Author: Aaron Conole <aconole@redhat.com> Date: Tue Dec 20 16:27:17 2022 -0500 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 <wangchuanlei@inspur.com> Fixes: 1933ea3 ("net: openvswitch: Add support to count upcall packets") Reported-by: syzbot+8f4e2dcfcb3209ac35f9@syzkaller.appspotmail.com Signed-off-by: Aaron Conole <aconole@redhat.com> Acked-by: Eelco Chaudron <echaudro@redhat.com> Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com> Link: https://lore.kernel.org/r/20221220212717.526780-1-aconole@redhat.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Antoine Tenart <atenart@redhat.com>
1 parent ff50616 commit 988b7c8

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
@@ -1851,7 +1851,7 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)
18511851
vport->upcall_stats = netdev_alloc_pcpu_stats(struct vport_upcall_stats_percpu);
18521852
if (!vport->upcall_stats) {
18531853
err = -ENOMEM;
1854-
goto err_destroy_portids;
1854+
goto err_destroy_vport;
18551855
}
18561856

18571857
err = ovs_dp_cmd_fill_info(dp, reply, info->snd_portid,
@@ -1866,6 +1866,8 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)
18661866
ovs_notify(&dp_datapath_genl_family, reply, info);
18671867
return 0;
18681868

1869+
err_destroy_vport:
1870+
ovs_dp_detach_port(vport);
18691871
err_destroy_portids:
18701872
kfree(rcu_dereference_raw(dp->upcall_portids));
18711873
err_unlock_and_destroy_meters:
@@ -2312,7 +2314,7 @@ static int ovs_vport_cmd_new(struct sk_buff *skb, struct genl_info *info)
23122314
vport->upcall_stats = netdev_alloc_pcpu_stats(struct vport_upcall_stats_percpu);
23132315
if (!vport->upcall_stats) {
23142316
err = -ENOMEM;
2315-
goto exit_unlock_free;
2317+
goto exit_unlock_free_vport;
23162318
}
23172319

23182320
err = ovs_vport_cmd_fill_info(vport, reply, genl_info_net(info),
@@ -2332,6 +2334,8 @@ static int ovs_vport_cmd_new(struct sk_buff *skb, struct genl_info *info)
23322334
ovs_notify(&dp_vport_genl_family, reply, info);
23332335
return 0;
23342336

2337+
exit_unlock_free_vport:
2338+
ovs_dp_detach_port(vport);
23352339
exit_unlock_free:
23362340
ovs_unlock();
23372341
kfree_skb(reply);

0 commit comments

Comments
 (0)