From 853045599b90f3687d03a5e7203381b610cf12d3 Mon Sep 17 00:00:00 2001 From: Niu Yawei Date: Wed, 13 Nov 2013 23:48:00 -0500 Subject: [PATCH] LU-3772 ptlrpc: fix nrs cleanup When service start failed due to short of memory, the cleanup code could operate on uninitialized structure and cause crash at the end. This patch fix the nrs_svcpt_cleanup_locked() to perform cleanup only on the nrs which has been properly initialized. Signed-off-by: Niu Yawei Change-Id: Ieafa5b144133490b662f5a80a7b99311a9970de3 Reviewed-on: http://review.whamcloud.com/7410 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- lustre/ptlrpc/nrs.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lustre/ptlrpc/nrs.c b/lustre/ptlrpc/nrs.c index 069f6a0..b46d315 100644 --- a/lustre/ptlrpc/nrs.c +++ b/lustre/ptlrpc/nrs.c @@ -1024,7 +1024,13 @@ static void nrs_svcpt_cleanup_locked(struct ptlrpc_service_part *svcpt) LASSERT(mutex_is_locked(&nrs_core.nrs_mutex)); again: - nrs = nrs_svcpt2nrs(svcpt, hp); + /* scp_nrs_hp could be NULL due to short of memory. */ + nrs = hp ? svcpt->scp_nrs_hp : &svcpt->scp_nrs_reg; + /* check the nrs_svcpt to see if nrs is initialized. */ + if (!nrs || !nrs->nrs_svcpt) { + EXIT; + return; + } nrs->nrs_stopping = 1; cfs_list_for_each_entry_safe(policy, tmp, &nrs->nrs_policy_list, -- 1.8.3.1