From b13197d68f659e9f52fff0506a0fd5b1e557f7d7 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Fri, 6 Nov 2015 17:09:17 +0100 Subject: [PATCH] btrfs-progs: use on-stack buffer for dev_to_fsid Signed-off-by: David Sterba --- cmds-filesystem.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/cmds-filesystem.c b/cmds-filesystem.c index c6ed388e..25317fa9 100644 --- a/cmds-filesystem.c +++ b/cmds-filesystem.c @@ -510,18 +510,13 @@ out: static int dev_to_fsid(char *dev, __u8 *fsid) { struct btrfs_super_block *disk_super; - char *buf; + char buf[BTRFS_SUPER_INFO_SIZE]; int ret; int fd; - buf = malloc(4096); - if (!buf) - return -ENOMEM; - fd = open(dev, O_RDONLY); if (fd < 0) { ret = -errno; - free(buf); return ret; } @@ -536,7 +531,6 @@ static int dev_to_fsid(char *dev, __u8 *fsid) out: close(fd); - free(buf); return ret; }