diff mbox

[2/3] btrfs-progs: check malloc() result

Message ID 1352954872-13770-3-git-send-email-okimoto@clear-code.com (mailing list archive)
State New, archived
Headers show

Commit Message

Kenji Okimoto Nov. 15, 2012, 4:47 a.m. UTC
Signed-off-by: Kenji Okimoto <okimoto@clear-code.com>
---
 disk-io.c |    3 +++
 1 file changed, 3 insertions(+)
diff mbox

Patch

diff --git a/disk-io.c b/disk-io.c
index 32f45dc..c4d4631 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -458,6 +458,9 @@  static int find_and_setup_log_root(struct btrfs_root *tree_root,
 	u64 blocknr = btrfs_super_log_root(disk_super);
 	struct btrfs_root *log_root = malloc(sizeof(struct btrfs_root));
 
+	if (!log_root)
+		return -ENOMEM;
+
 	if (blocknr == 0) {
 		free(log_root);
 		return 0;