diff mbox

btrfs-progs: fix memory leak with missing device

Message ID 20160728174411.4998-1-jmaggard@netgear.com (mailing list archive)
State Accepted
Headers show

Commit Message

Justin Maggard July 28, 2016, 5:44 p.m. UTC
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.

Signed-off-by: Justin Maggard <jmaggard@netgear.com>
---
 volumes.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

David Sterba July 29, 2016, 2:46 p.m. UTC | #1
On Thu, Jul 28, 2016 at 10:44:11AM -0700, Justin Maggard wrote:
> 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.
> 
> Signed-off-by: Justin Maggard <jmaggard@netgear.com>

Applied (to 4.7), thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/volumes.c b/volumes.c
index ccfa732..b5066b9 100644
--- a/volumes.c
+++ b/volumes.c
@@ -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);
 		}
 
 	}