Skip to contentSkip to conversation

NULL-deref and leak fixes: rebased against new git tree

PATCH Jim Meyering 1 participant 1 message Sep 30, 2008 Btrfs file system

lore
Share & tools
lore
#0 lore raw

I posted two patches during the wrong week (plumbers), so you may have missed them on the mailing list:

    http://article.gmane.org/gmane.comp.file-systems.btrfs/1222
    http://article.gmane.org/gmane.comp.file-systems.btrfs/1223

Since then, the official tree converted to using git, so I've rebased the patches against it and adjusted the log messages:

Quoted 1 line

From 494bed7b1f361c13d22b9c4e0a0e7205e2eb3d19 Mon Sep 17 00:00:00 2001

From: Jim Meyering <[email protected]>
Date: Sun, 14 Sep 2008 22:08:09 +0200
Subject: [PATCH] Btrfs: disk-io.c (open_ctree): Don't deref. NULL upon failed kzalloc

---
 fs/btrfs/disk-io.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
fs/btrfs/disk-io.c +2 -1
index 5ee10d3..a20b034 100644
@@ -1371,7 +1371,8 @@ struct btrfs_root *open_ctree(struct super_block *sb,
 
 	struct btrfs_super_block *disk_super;
 
-	if (!extent_root || !tree_root || !fs_info) {
+	if (!extent_root || !tree_root || !fs_info
+	    || !chunk_root || !dev_root) {
 		err = -ENOMEM;
 		goto fail;
 	}
Signature · 1 line
1.6.0.2.27.gea240
Quoted 1 line

From 5a675eb3d8b745cd6d3fba59cc122eca8ad45b80 Mon Sep 17 00:00:00 2001

From: Jim Meyering <[email protected]>
Date: Tue, 30 Sep 2008 10:05:21 +0200
Subject: [PATCH] Btrfs: disk-io.c (open_ctree): avoid leaks-upon-allocation-failure

---
 fs/btrfs/disk-io.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
fs/btrfs/disk-io.c +2 -0
index a20b034..d956b0e 100644
@@ -1699,6 +1699,8 @@ fail:
 	kfree(tree_root);
 	bdi_destroy(&fs_info->bdi);
 	kfree(fs_info);
+	kfree(chunk_root);
+	kfree(dev_root);
 	return ERR_PTR(err);
 }
 
Signature · 1 line
1.6.0.2.27.gea240