From 94f3b75c00752167274c1aa4dfceab13f3c58b49 Mon Sep 17 00:00:00 2001 From: Sidong Yang Date: Sat, 26 Jun 2021 15:03:44 +0000 Subject: [PATCH] btrfs-progs: zoned: fix memory leak in btrfs_sb_io() 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. Reviewed-by: Qu Wenruo Reviewed-by: Naohiro Aota Signed-off-by: Sidong Yang Signed-off-by: David Sterba --- kernel-shared/zoned.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel-shared/zoned.c b/kernel-shared/zoned.c index 1cf8a582..31352c9c 100644 --- a/kernel-shared/zoned.c +++ b/kernel-shared/zoned.c @@ -552,6 +552,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.