The definition of struct blk_zone_report is as follows: struct blk_zone_report { __u64 sector; __u32 nr_zones; __u32 flags; struct blk_zone zones[0]; };
Since f2fs_report_zone() allocates the above data structure with malloc() and since f2fs_report_zone() only initializes the sector and nr_zones members, the flags member is not initialized. Modify f2fs_report_zone() such that 0 is passed as flags to the BLKREPORTZONE ioctl instead of a random value. This has been discovered by reading the source code. Cc: Shin'ichiro Kawasaki <shinichiro.kawas...@wdc.com> Fixes: 6d7c7b785feb ("libf2fs_zoned: Introduce f2fs_report_zone() helper function") Signed-off-by: Bart Van Assche <bvanass...@acm.org> --- lib/libf2fs_zoned.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/libf2fs_zoned.c b/lib/libf2fs_zoned.c index f383ce275342..d8de66b82029 100644 --- a/lib/libf2fs_zoned.c +++ b/lib/libf2fs_zoned.c @@ -206,7 +206,8 @@ int f2fs_report_zone(int i, uint64_t sector, void *blkzone) struct blk_zone_report *rep; int ret = -1; - rep = malloc(sizeof(struct blk_zone_report) + sizeof(struct blk_zone)); + rep = calloc(1, sizeof(struct blk_zone_report) + + sizeof(struct blk_zone)); if (!rep) { ERR_MSG("No memory for report zones\n"); return -ENOMEM; _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel