From cd362fa9186a3e4de34c7c68908e6d3d429bb087 Mon Sep 17 00:00:00 2001 From: Li Xi Date: Tue, 17 Nov 2015 17:07:00 +0800 Subject: [PATCH] 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 --- lustre/ptlrpc/nrs_tbf.c | 8 ++++++++ 1 file changed, 8 insertions(+) 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; } -- 1.8.3.1