Whamcloud - gitweb
LU-7441 nrs: Free hash table if failed to start a nrs policy 24/17224/6
authorLi Xi <lixi@ddn.com>
Tue, 17 Nov 2015 09:07:00 +0000 (17:07 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 1 Mar 2017 05:10:12 +0000 (05:10 +0000)
Hash table should be freed correctly if failed to start a nrs policy,
otherwise it will cause memory leak.

Signed-off-by: Li Xi <lixi@ddn.com>
Signed-off-by: Emoly Liu <emoly.liu@intel.com>
Change-Id: Ib5380fab1843af129f4cbf7ac396fb620bb8a617
Reviewed-on: https://review.whamcloud.com/17224
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/ptlrpc/nrs_tbf.c

index f3ba8f0..348a9e8 100644 (file)
@@ -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;
 }