All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wilfred Mallawa <wilfred.opensource@gmail.com>
To: linux-xfs@vger.kernel.org
Cc: Wilfred Mallawa <wilfred.mallawa@wdc.com>
Subject: [xfsprogs] mkfs: fixup memory leak on exit
Date: Tue,  6 Oct 2026 12:12:33 +0200	[thread overview]
Message-ID: <20261006101232.357124-2-wilfred.opensource@gmail.com> (raw)

From: Wilfred Mallawa <wilfred.mallawa@wdc.com>

When running mkfs.xfs with addrsan enabled, the following is reported:

```
==27832==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 9 byte(s) in 1 object(s) allocated from:
    #0 0x7fe6db2e8ac4 in strdup (/lib64/libasan.so.8+0xe8ac4) (BuildId: 5395ec74f54d9ec7bf97c06583dd39a96c230822)
    #1 0x0000004175ce in getstr <blah>/mkfs/xfs_mkfs.c:1767

SUMMARY: AddressSanitizer: 9 byte(s) leaked in 1 allocation(s).
```

Thus, gracefully clean up these string allocation on exit to address the above.

Signed-off-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
---
 mkfs/xfs_mkfs.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 334367b8..fec43987 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -6503,5 +6503,8 @@ main(
 		exit(1);
 
 	libxfs_destroy(&xi);
+	free(cli.xi->data.name);
+	free(cli.xi->log.name);
+	free(cli.xi->rt.name);
 	return 0;
 }
-- 
2.55.0


             reply	other threads:[~2026-10-06 10:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-06 10:12 Wilfred Mallawa [this message]
2026-10-06 10:51 ` [xfsprogs] mkfs: fixup memory leak on exit Carlos Maiolino
2026-10-06 13:52   ` Wilfred Mallawa
2026-10-06 14:48     ` Darrick J. Wong
2026-10-06 15:20       ` Wilfred Mallawa
2026-10-08  7:17       ` Christoph Hellwig
2026-10-08 11:20       ` Carlos Maiolino
2026-10-11  1:32         ` Wilfred Mallawa
2026-10-11  7:09           ` Carlos Maiolino
2026-10-12  0:43             ` Wilfred Mallawa

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=20261006101232.357124-2-wilfred.opensource@gmail.com \
    --to=wilfred.opensource@gmail.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=wilfred.mallawa@wdc.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.