btrfs-progs: zoned: fix memory leak in btrfs_sb_io()
PATCH 1/1 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.
--- kernel-shared/zoned.c | 1 + 1 file changed, 1 insertion(+)
kernel-shared/zoned.c +1 -0
@@ -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.
Signature · 1 line
2.25.1
Quoted 5 lines · Sidong Yang
In
btrfs_sb_io(),blk_zone_reportis 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 <[email protected]>
Thanks,
Qu
Quoted 17 lines
--- kernel-shared/zoned.c | 1 + 1 file changed, 1 insertion(+)kernel-shared/zoned.c +1
-0@@ -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.
Quoted 5 lines · Sidong Yang
In
btrfs_sb_io(),blk_zone_reportis 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 <[email protected]>
Thanks for catching this. Looks good.
Quoted 19 lines
--- kernel-shared/zoned.c | 1 + 1 file changed, 1 insertion(+)kernel-shared/zoned.c +1
-0@@ -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. Signature · 1 line
2.25.1
Quoted 5 lines · Sidong Yang
In
btrfs_sb_io(),blk_zone_reportis 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 <[email protected]>
Added to devel, thanks.