From: Li Xi Date: Tue, 17 Nov 2015 09:07:00 +0000 (+0800) Subject: LU-7441 nrs: Free hash table if failed to start a nrs policy X-Git-Tag: 2.9.54~33 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F24%2F17224%2F6;p=fs%2Flustre-release.git LU-7441 nrs: Free hash table if failed to start a nrs policy Hash table should be freed correctly if failed to start a nrs policy, otherwise it will cause memory leak. Signed-off-by: Li Xi Signed-off-by: Emoly Liu Change-Id: Ib5380fab1843af129f4cbf7ac396fb620bb8a617 Reviewed-on: https://review.whamcloud.com/17224 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin --- diff --git a/lustre/ptlrpc/nrs_tbf.c b/lustre/ptlrpc/nrs_tbf.c index f3ba8f0..348a9e8 100644 --- a/lustre/ptlrpc/nrs_tbf.c +++ b/lustre/ptlrpc/nrs_tbf.c @@ -787,6 +787,10 @@ nrs_tbf_jobid_startup(struct ptlrpc_nrs_policy *policy, start.tc_name = NRS_TBF_DEFAULT_RULE; INIT_LIST_HEAD(&start.u.tc_start.ts_jobids); rc = nrs_tbf_rule_start(policy, head, &start); + if (rc) { + cfs_hash_putref(head->th_cli_hash); + head->th_cli_hash = NULL; + } return rc; } @@ -1116,6 +1120,10 @@ nrs_tbf_nid_startup(struct ptlrpc_nrs_policy *policy, start.tc_name = NRS_TBF_DEFAULT_RULE; INIT_LIST_HEAD(&start.u.tc_start.ts_nids); rc = nrs_tbf_rule_start(policy, head, &start); + if (rc) { + cfs_hash_putref(head->th_cli_hash); + head->th_cli_hash = NULL; + } return rc; }