From 7c3d518d72446846c27539c0886a847a78ed8235 Mon Sep 17 00:00:00 2001 From: Niu Yawei Date: Wed, 13 Nov 2013 23:48:00 -0500 Subject: [PATCH 1/1] 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 4a3c976..6d02aa52 100644 --- a/lustre/ptlrpc/nrs.c +++ b/lustre/ptlrpc/nrs.c @@ -1019,7 +1019,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