Thread (4 messages) 4 messages, 4 authors, 2021-07-01

Re: [PATCH] btrfs-progs: zoned: fix memory leak in btrfs_sb_io()

From: Naohiro Aota <Naohiro.Aota@wdc.com>
Date: 2021-06-28 04:44:07

On Sat, Jun 26, 2021 at 03:03:44PM +0000, Sidong Yang wrote:
In btrfs_sb_io(), blk_zone_report is used for getting information about
zones. But it is not freed if code goes in usual path. This patch frees
the variable just after it used.

Signed-off-by: Sidong Yang <redacted>
Thanks for catching this. Looks good.

Reviewed-by: Naohiro Aota <naohiro.aota@wdc.com>
quoted hunk ↗ jump to hunk
---
 kernel-shared/zoned.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/kernel-shared/zoned.c b/kernel-shared/zoned.c
index 2a6892b3..75eade84 100644
--- a/kernel-shared/zoned.c
+++ b/kernel-shared/zoned.c
@@ -543,6 +543,7 @@ size_t btrfs_sb_io(int fd, void *buf, off_t offset, int rw)
 	zones = (struct blk_zone *)(rep + 1);
 
 	ret = sb_log_location(fd, zones, rw, &mapped);
+	free(rep);	
 	/*
 	 * Special case: no superblock found in the zones. This case happens
 	 * when initializing a file-system.
-- 
2.25.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help