From 416d39c48a5980177fbca3eed314322c456a0a54 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Fri, 6 Nov 2015 17:34:45 +0100 Subject: [PATCH] btrfs-progs: use on-stack variable in __rebuild_device_items Signed-off-by: David Sterba --- chunk-recover.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/chunk-recover.c b/chunk-recover.c index f8693f7f..51464898 100644 --- a/chunk-recover.c +++ b/chunk-recover.c @@ -1191,13 +1191,10 @@ static int __rebuild_device_items(struct btrfs_trans_handle *trans, { struct btrfs_device *dev; struct btrfs_key key; - struct btrfs_dev_item *dev_item; + struct btrfs_dev_item dev_item_tmp; + struct btrfs_dev_item *dev_item = &dev_item_tmp; int ret = 0; - dev_item = malloc(sizeof(struct btrfs_dev_item)); - if (!dev_item) - return -ENOMEM; - list_for_each_entry(dev, &rc->fs_devices->devices, dev_list) { key.objectid = BTRFS_DEV_ITEMS_OBJECTID; key.type = BTRFS_DEV_ITEM_KEY; @@ -1218,7 +1215,6 @@ static int __rebuild_device_items(struct btrfs_trans_handle *trans, dev_item, sizeof(*dev_item)); } - free(dev_item); return ret; }