linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Reichl <preichl@redhat.com>
To: jack@suse.cz
Cc: linux-fsdevel@vger.kernel.org
Subject: [PATCH] quotaio_xfs: Fix memory leak
Date: Tue, 30 Jul 2024 00:18:13 +0200	[thread overview]
Message-ID: <20240729221813.93878-1-preichl@redhat.com> (raw)

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.45.2


             reply	other threads:[~2024-07-29 22:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-29 22:18 Pavel Reichl [this message]
2024-07-30 12:50 ` [PATCH] quotaio_xfs: Fix memory leak Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240729221813.93878-1-preichl@redhat.com \
    --to=preichl@redhat.com \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).