From patchwork Thu Feb 27 21:17:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11410695 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 423DE924 for ; Thu, 27 Feb 2020 21:44:39 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2987124690 for ; Thu, 27 Feb 2020 21:44:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2987124690 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id E2B9634AE7D; Thu, 27 Feb 2020 13:35:41 -0800 (PST) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id A4BA021FD2E for ; Thu, 27 Feb 2020 13:21:14 -0800 (PST) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id E5A1591D0; Thu, 27 Feb 2020 16:18:19 -0500 (EST) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id E459B46D; Thu, 27 Feb 2020 16:18:19 -0500 (EST) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 27 Feb 2020 16:17:13 -0500 Message-Id: <1582838290-17243-566-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1582838290-17243-1-git-send-email-jsimmons@infradead.org> References: <1582838290-17243-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 565/622] lnet: fix rspt counter X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexey Lyashkov , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Alexey Lyashkov rsp entries must freed via lnet_rspt_free function to avoid counter leak. handle NULL allocation properly. Cray-bug-id: LUS-8189 WC-bug-id: https://jira.whamcloud.com/browse/LU-12991 Lustre-commit: 027a4722b26d ("LU-12991 lnet: fix rspt counter") Signed-off-by: Alexey Lyashkov Reviewed-on: https://review.whamcloud.com/36895 Reviewed-by: Alexandr Boyko Reviewed-by: Chris Horn Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- include/linux/lnet/lib-lnet.h | 8 +++++--- net/lnet/lnet/lib-move.c | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/linux/lnet/lib-lnet.h b/include/linux/lnet/lib-lnet.h index 56556fd..3b597e3 100644 --- a/include/linux/lnet/lib-lnet.h +++ b/include/linux/lnet/lib-lnet.h @@ -438,9 +438,11 @@ void lnet_res_lh_initialize(struct lnet_res_container *rec, struct lnet_rsp_tracker *rspt; rspt = kzalloc(sizeof(*rspt), GFP_NOFS); - lnet_net_lock(cpt); - the_lnet.ln_counters[cpt]->lct_health.lch_rst_alloc++; - lnet_net_unlock(cpt); + if (rspt) { + lnet_net_lock(cpt); + the_lnet.ln_counters[cpt]->lct_health.lch_rst_alloc++; + lnet_net_unlock(cpt); + } return rspt; } diff --git a/net/lnet/lnet/lib-move.c b/net/lnet/lnet/lib-move.c index da73009..73f9d20 100644 --- a/net/lnet/lnet/lib-move.c +++ b/net/lnet/lnet/lib-move.c @@ -4390,7 +4390,7 @@ void lnet_monitor_thr_stop(void) /* we already have an rspt attached to the md, so we'll * update the deadline on that one. */ - kfree(rspt); + lnet_rspt_free(rspt, cpt); new_entry = false; } else { /* new md */ @@ -4511,7 +4511,7 @@ void lnet_monitor_thr_stop(void) md->md_me->me_portal); lnet_res_unlock(cpt); - kfree(rspt); + lnet_rspt_free(rspt, cpt); kfree(msg); return -ENOENT; } @@ -4745,7 +4745,7 @@ struct lnet_msg * lnet_res_unlock(cpt); kfree(msg); - kfree(rspt); + lnet_rspt_free(rspt, cpt); return -ENOENT; }