From d1ce9c2033fcbd4ee73c4b22abb6cf11db968bd2 Mon Sep 17 00:00:00 2001 From: Yifeng Sun Date: Wed, 15 Nov 2017 06:59:24 -0800 Subject: [PATCH] dpif-netdev: Fix memory leak Valgrind complains in test 1019 (dpctl - add-if set-if del-if): 4,850,896 (4,850,240 direct, 656 indirect) bytes in 1 blocks are definitely lost in loss record 364 of 364 by 0x517062: xcalloc (util.c:103) by 0x46CBBC: dp_netdev_set_nonpmd (dpif-netdev.c:4498) by 0x46CBBC: create_dp_netdev (dpif-netdev.c:1299) by 0x46CBBC: dpif_netdev_open (dpif-netdev.c:1337) by 0x472CB0: do_open (dpif.c:350) by 0x472E6F: dpif_create (dpif.c:404) by 0x472E6F: dpif_create_and_open (dpif.c:417) by 0x430EBC: open_dpif_backer (ofproto-dpif.c:727) by 0x430EBC: construct (ofproto-dpif.c:1411) by 0x41B714: ofproto_create (ofproto.c:539) by 0x40C84E: bridge_reconfigure (bridge.c:647) by 0x4104C5: bridge_run (bridge.c:2998) by 0x406FA4: main (ovs-vswitchd.c:119) The reference count wasn't released at this earlier return. This fix passes the test 'make check'. Signed-off-by: Yifeng Sun Tested-by: Greg Rose Reviewed-by: Greg Rose Signed-off-by: Ian Stokes --- lib/dpif-netdev.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index bd38870f0..4e5bdbebb 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -2925,6 +2925,9 @@ dpif_netdev_execute(struct dpif *dpif, struct dpif_execute *execute) /* If this is part of a probe, Drop the packet, since executing * the action may actually cause spurious packets be sent into * the network. */ + if (pmd->core_id == NON_PMD_CORE_ID) { + dp_netdev_pmd_unref(pmd); + } return 0; }