mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] xfs: Fix a memory leak bug in xfs_buf_item_init()
@ 2025-12-06 12:15 Haoxiang Li
  2025-12-08  6:49 ` Christoph Hellwig
  0 siblings, 1 reply; 2+ messages in thread
From: Haoxiang Li @ 2025-12-06 12:15 UTC (permalink / raw)
  To: cem, darrick.wong; +Cc: linux-xfs, linux-kernel, Haoxiang Li, stable

xfs_buf_item_get_format() may allocate memory for bip->bli_formats,
free the memory in the error path.

Fixes: c3d5f0c2fb85 ("xfs: complain if anyone tries to create a too-large buffer log item")
Cc: stable@vger.kernel.org
Signed-off-by: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
---
 fs/xfs/xfs_buf_item.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index 8d85b5eee444..f4c5be67826e 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -896,6 +896,7 @@ xfs_buf_item_init(
 		map_size = DIV_ROUND_UP(chunks, NBWORD);
 
 		if (map_size > XFS_BLF_DATAMAP_SIZE) {
+			xfs_buf_item_free_format(bip);
 			kmem_cache_free(xfs_buf_item_cache, bip);
 			xfs_err(mp,
 	"buffer item dirty bitmap (%u uints) too small to reflect %u bytes!",
-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] xfs: Fix a memory leak bug in xfs_buf_item_init()
  2025-12-06 12:15 [PATCH] xfs: Fix a memory leak bug in xfs_buf_item_init() Haoxiang Li
@ 2025-12-08  6:49 ` Christoph Hellwig
  0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2025-12-08  6:49 UTC (permalink / raw)
  To: Haoxiang Li; +Cc: cem, darrick.wong, linux-xfs, linux-kernel, stable

s/memory leak bug/memory leak/ in the subject.

Otherwise looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-12-08  6:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-06 12:15 [PATCH] xfs: Fix a memory leak bug in xfs_buf_item_init() Haoxiang Li
2025-12-08  6:49 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®