btrfs-progs: add malloc check in transaction.h/btrfs_start_transaction
authorWang Sheng-Hui <shhuiw@gmail.com>
Thu, 16 Aug 2012 12:15:56 +0000 (20:15 +0800)
committerDavid Sterba <dsterba@suse.cz>
Fri, 18 Jan 2013 17:27:21 +0000 (18:27 +0100)
For malloc may fail, we should check it before assign
values to the struct btrfs_trans_handle *h.

Signed-off-by: Wang Sheng-Hui <shhuiw@gmail.com>
transaction.h

index a1070e0..e8610b1 100644 (file)
@@ -34,6 +34,7 @@ btrfs_start_transaction(struct btrfs_root *root, int num_blocks)
        struct btrfs_fs_info *fs_info = root->fs_info;
        struct btrfs_trans_handle *h = malloc(sizeof(*h));
 
+       BUG_ON(!h);
        BUG_ON(root->commit_root);
        BUG_ON(fs_info->running_transaction);
        fs_info->running_transaction = h;