Whamcloud - gitweb
LU-15440 lnet: lnet_peer_data_present() memory leak 52/46052/3
authorChris Horn <chris.horn@hpe.com>
Tue, 11 Jan 2022 22:19:16 +0000 (16:19 -0600)
committerOleg Drokin <green@whamcloud.com>
Mon, 7 Feb 2022 04:43:24 +0000 (04:43 +0000)
If the ping buffer has nnis <= 1 then the ref on the ping buffer does
not get dropped. This causes a memory leak.

Test-Parameters: trivial testlist=sanity-lnet
Signed-off-by: Chris Horn <chris.horn@hpe.com>
Change-Id: I5e3c651ffecbe4f8860afb86770cecef23ebe862
Reviewed-on: https://review.whamcloud.com/46052
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Serguei Smirnov <ssmirnov@whamcloud.com>
Reviewed-by: Andriy Skulysh <andriy.skulysh@hpe.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Alexey Lyashkov <alexey.lyashkov@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/lnet/peer.c
lustre/tests/sanity-lnet.sh

index 853cfe5..ba2f84d 100644 (file)
@@ -3362,8 +3362,10 @@ __must_hold(&lp->lp_lock)
         * primary NID to the correct value here. Moreover, this peer
         * can show up with only the loopback NID in the ping buffer.
         */
-       if (pbuf->pb_info.pi_nnis <= 1)
+       if (pbuf->pb_info.pi_nnis <= 1) {
+               lnet_ping_buffer_decref(pbuf);
                goto out;
+       }
        nid = pbuf->pb_info.pi_ni[1].ns_nid;
        if (nid_is_lo0(&lp->lp_primary_nid)) {
                rc = lnet_peer_set_primary_nid(lp, nid, flags);
index 860f712..72e28eb 100755 (executable)
@@ -2335,6 +2335,19 @@ test_216() {
 }
 run_test 216 "Failed send to peer NI owned by local host should not trigger peer NI recovery"
 
+test_217() {
+       reinit_dlc || return $?
+
+       [[ $($LNETCTL net show | grep -c nid) -ne 1 ]] &&
+               error "Unexpected number of NIs after initalizing DLC"
+
+       do_lnetctl discover 0@lo ||
+               error "Failed to discover 0@lo"
+
+       unload_modules
+}
+run_test 217 "Don't leak memory when discovering peer with nnis <= 1"
+
 test_230() {
        # LU-12815
        echo "Check valid values; Should succeed"