staging: lustre: 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 <yawei.niu@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3772
Reviewed-on: http://review.whamcloud.com/7410
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Niu Yawei 2016-05-04 10:28:58 -04:00 committed by Greg Kroah-Hartman
parent 4fd9a8e937
commit 2ff1d8fbba
1 changed files with 5 additions and 1 deletions

View File

@ -975,7 +975,11 @@ 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)
return;
nrs->nrs_stopping = 1;
list_for_each_entry_safe(policy, tmp, &nrs->nrs_policy_list, pol_list) {