From: Alex Zhuravlev Date: Tue, 26 Mar 2024 14:41:18 +0000 (+0300) Subject: LU-17678 quota: fix memleak in qmt_setup_lqe_gd() X-Git-Tag: 2.15.62~7 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=refs%2Fchanges%2F75%2F54575%2F3;p=fs%2Flustre-release.git LU-17678 quota: fix memleak in qmt_setup_lqe_gd() a race in qmt_setup_lqe_gd() can lead to leaked lqe_glbl_data. Signed-off-by: Alex Zhuravlev Change-Id: I807aa276fa373cec493cae9d8182b28d996f5a8b Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/54575 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin Reviewed-by: Sergey Cheremencev Reviewed-by: Andreas Dilger --- diff --git a/lustre/quota/qmt_entry.c b/lustre/quota/qmt_entry.c index 6c37036..5a55034 100644 --- a/lustre/quota/qmt_entry.c +++ b/lustre/quota/qmt_entry.c @@ -1323,7 +1323,15 @@ void qmt_setup_lqe_gd(const struct lu_env *env, struct qmt_device *qmt, lqe_qtype(lqe), &lqe->lqe_id); qmt_seed_glbe(env, lgd, false); - lqe->lqe_glbl_data = lgd; + mutex_lock(&lqe->lqe_glbl_data_lock); + if (lqe->lqe_glbl_data == NULL) { + lqe->lqe_glbl_data = lgd; + lgd = NULL; + } + mutex_unlock(&lqe->lqe_glbl_data_lock); + if (lgd) + qmt_free_lqe_gd(lgd); + qmt_id_lock_notify(qmt, lqe); qti_lqes_fini(env);