btrfs-progs: check: Fix heap use after free
[platform/upstream/btrfs-progs.git] / btrfs-map-logical.c
index f421a50..e856b69 100644 (file)
@@ -29,8 +29,9 @@
 #include "transaction.h"
 #include "list.h"
 #include "utils.h"
+#include "help.h"
 
-#define BUFFER_SIZE (64 * 1024)
+#define BUFFER_SIZE SZ_64K
 
 /* we write the mirror info to stdout unless they are dumping the data
  * to stdout
@@ -125,7 +126,7 @@ static int __print_mapping_info(struct btrfs_fs_info *fs_info, u64 logical,
                                multi->stripes[0].physical,
                                device->name);
                }
-               kfree(multi);
+               free(multi);
                multi = NULL;
                cur_offset += cur_len;
        }
@@ -193,11 +194,11 @@ static int write_extent_content(struct btrfs_fs_info *fs_info, int out_fd,
 static void print_usage(void) __attribute__((noreturn));
 static void print_usage(void)
 {
-       fprintf(stderr, "usage: btrfs-map-logical [options] device\n");
-       fprintf(stderr, "\t-l Logical extent to map\n");
-       fprintf(stderr, "\t-c Copy of the extent to read (usually 1 or 2)\n");
-       fprintf(stderr, "\t-o Output file to hold the extent\n");
-       fprintf(stderr, "\t-b Number of bytes to read\n");
+       printf("usage: btrfs-map-logical [options] device\n");
+       printf("\t-l Logical extent to map\n");
+       printf("\t-c Copy of the extent to read (usually 1 or 2)\n");
+       printf("\t-o Output file to hold the extent\n");
+       printf("\t-b Number of bytes to read\n");
        exit(1);
 }