Skip to contentSkip to conversation

btrfs-progs: fix memory leak with missing device

PATCH In review Justin Maggard 2 participants 2 messages Jul 28, 2016 – Jul 29, 2016 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs-progs: fix memory leak with missing device

In read_one_chunk(), we may add an empty entry for a missing device. However, this entry wasn't being added to the dev_list, and so it never got freed.

---
 volumes.c | 2 ++
 1 file changed, 2 insertions(+)
volumes.c +2 -0
index ccfa732..b5066b9 100644
@@ -1759,6 +1759,8 @@ static int read_one_chunk(struct btrfs_root *root, struct btrfs_key *key,
 			map->stripes[i].dev = fill_missing_device(devid);
 			printf("warning, device %llu is missing\n",
 			       (unsigned long long)devid);
+			list_add(&map->stripes[i].dev->dev_list,
+				 &root->fs_info->fs_devices->devices);
 		}
 
 	}
Signature · 1 line
2.9.2
#1 lore raw
Quoted 5 lines · Justin Maggard

In read_one_chunk(), we may add an empty entry for a missing device. However, this entry wasn't being added to the dev_list, and so it never got freed.

Applied (to 4.7), thanks.