From 440c1c03fe08df2ea626d8658ab9960ad108e19d Mon Sep 17 00:00:00 2001 From: Amir Shehata Date: Fri, 25 Aug 2017 21:26:00 -0700 Subject: [PATCH] LU-9918 lnet: decref on peer after use After looking up the peer for both ping and discover we need to decref the peer so we don't lose a reference on it. This needs to be done while the mutex_lock is held to ensure the peer list remains stable. Signed-off-by: Amir Shehata Change-Id: Ic57e67d21b8afe17a239cc496621bc4abf681077 Reviewed-on: https://review.whamcloud.com/28722 Tested-by: Jenkins Reviewed-by: John L. Hammond Tested-by: Maloo Reviewed-by: Sonia Sharma Reviewed-by: Olaf Weber Reviewed-by: Oleg Drokin --- lnet/lnet/api-ni.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lnet/lnet/api-ni.c b/lnet/lnet/api-ni.c index db67866..c725e6e 100644 --- a/lnet/lnet/api-ni.c +++ b/lnet/lnet/api-ni.c @@ -3325,11 +3325,15 @@ LNetCtl(unsigned int cmd, void *arg) if (rc < 0) return rc; + mutex_lock(&the_lnet.ln_api_mutex); lp = lnet_find_peer(ping->ping_id.nid); if (lp) { ping->ping_id.nid = lp->lp_primary_nid; ping->mr_info = lnet_peer_is_multi_rail(lp); + lnet_peer_decref_locked(lp); } + mutex_unlock(&the_lnet.ln_api_mutex); + ping->ping_count = rc; return 0; } @@ -3343,11 +3347,15 @@ LNetCtl(unsigned int cmd, void *arg) discover->ping_count); if (rc < 0) return rc; + + mutex_lock(&the_lnet.ln_api_mutex); lp = lnet_find_peer(discover->ping_id.nid); if (lp) { discover->ping_id.nid = lp->lp_primary_nid; discover->mr_info = lnet_peer_is_multi_rail(lp); + lnet_peer_decref_locked(lp); } + mutex_unlock(&the_lnet.ln_api_mutex); discover->ping_count = rc; return 0; -- 1.8.3.1