With commit
        87c09f7 Btrfs-progs: fix memory leaks on cleanup

mkfs on multiple dev is ending with segfault at
close_all_devices() during kfree(device->name)

because mkfs calls btrfs_add_to_fsid, which does not initialize
name when dev is added to the list.

Signed-off-by: Anand Jain <[email protected]>
---
 utils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/utils.c b/utils.c
index 412de80..7b4cd74 100644
--- a/utils.c
+++ b/utils.c
@@ -482,7 +482,7 @@ int btrfs_add_to_fsid(struct btrfs_trans_handle *trans,
        u64 num_devs;
        int ret;
 
-       device = kmalloc(sizeof(*device), GFP_NOFS);
+       device = kzalloc(sizeof(*device), GFP_NOFS);
        if (!device)
                return -ENOMEM;
        buf = kmalloc(sectorsize, GFP_NOFS);
-- 
1.8.1.227.g44fe835

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to