Linux-XFS Archive mirror
 help / color / mirror / Atom feed
From: Andrey Albershteyn <aalbersh@redhat.com>
To: cem@kernel.org, linux-xfs@vger.kernel.org
Cc: djwong@kernel.org, hch@infradead.org,
	Andrey Albershteyn <aalbersh@redhat.com>,
	Bill O'Donnell <bodonnel@redhat.com>,
	Christoph Hellwig <hch@lst.de>
Subject: [PATCH v4 1/4] xfs_db: fix leak in flist_find_ftyp()
Date: Wed, 17 Apr 2024 18:16:43 +0200	[thread overview]
Message-ID: <20240417161646.963612-2-aalbersh@redhat.com> (raw)
In-Reply-To: <20240417161646.963612-1-aalbersh@redhat.com>

When count is zero fl reference is lost. Fix it by freeing the list.

Fixes: a0d79cb37a36 ("xfs_db: make flist_find_ftyp() to check for field existance on disk")
Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Bill O'Donnell <bodonnel@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
 db/flist.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/db/flist.c b/db/flist.c
index c81d229ab99c..0a6cc5fcee43 100644
--- a/db/flist.c
+++ b/db/flist.c
@@ -424,8 +424,10 @@ flist_find_ftyp(
 		if (f->ftyp == type)
 			return fl;
 		count = fcount(f, obj, startoff);
-		if (!count)
+		if (!count) {
+			flist_free(fl);
 			continue;
+		}
 		fa = &ftattrtab[f->ftyp];
 		if (fa->subfld) {
 			flist_t *nfl;
-- 
2.42.0


  reply	other threads:[~2024-04-17 16:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-17 16:16 [PATCH v4 0/4] xfsprogs random fixes found by Coverity scan Andrey Albershteyn
2024-04-17 16:16 ` Andrey Albershteyn [this message]
2024-04-17 16:16 ` [PATCH v4 2/4] xfs_repair: make duration take time_t Andrey Albershteyn
2024-04-18  4:26   ` Christoph Hellwig
2024-04-23 12:06   ` Carlos Maiolino
2024-04-17 16:16 ` [PATCH v4 3/4] xfs_scrub: don't call phase_end if phase_rusage was not initialized Andrey Albershteyn
2024-04-18  4:26   ` Christoph Hellwig
2024-04-17 16:16 ` [PATCH v4 4/4] xfs_fsr: convert fsrallfs to use time_t instead of int Andrey Albershteyn
2024-04-18  4:27   ` Christoph Hellwig

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=20240417161646.963612-2-aalbersh@redhat.com \
    --to=aalbersh@redhat.com \
    --cc=bodonnel@redhat.com \
    --cc=cem@kernel.org \
    --cc=djwong@kernel.org \
    --cc=hch@infradead.org \
    --cc=hch@lst.de \
    --cc=linux-xfs@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 read-only IMAP folder(s) and NNTP newsgroup(s).