quota/0009-quotaio_xfs-Fix-memory-leak.patch
lvyy a11cd899d8 quotaio_xfs: Fix error handling in xfs_read_dquot()
(cherry picked from commit 648f3151b5aa6a0b532d1e9ef59c2a7db40d20ed)
2025-05-09 09:51:34 +08:00

31 lines
996 B
Diff

From c59b85805ee64c7ee2937b91533eb96f56d87738 Mon Sep 17 00:00:00 2001
From: Pavel Reichl <preichl@redhat.com>
Date: Tue, 30 Jul 2024 00:18:13 +0200
Subject: [PATCH] quotaio_xfs: Fix memory leak
Error: RESOURCE_LEAK (CWE-772):
quota-4.09/quotaio_xfs.c:162:2: alloc_fn: Storage is returned from allocation function "get_empty_dquot".
quota-4.09/quotaio_xfs.c:162:2: var_assign: Assigning: "dquot" = storage returned from "get_empty_dquot()".
quota-4.09/quotaio_xfs.c:180:4: leaked_storage: Variable "dquot" going out of scope leaks the storage it points to.
Signed-off-by: Pavel Reichl <preichl@redhat.com>
---
quotaio_xfs.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/quotaio_xfs.c b/quotaio_xfs.c
index 2df27b5..5446bc5 100644
--- a/quotaio_xfs.c
+++ b/quotaio_xfs.c
@@ -174,6 +174,7 @@ static struct dquot *xfs_read_dquot(struct quota_handle *h, qid_t id)
* zeros. Otherwise return failure.
*/
if (errno != ENOENT) {
+ free(dquot);
return NULL;
}
}
--
2.33.0