btrfs-progs: add malloc check in transaction.h/btrfs_start_transaction

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>
This commit is contained in:
Wang Sheng-Hui 2012-08-16 20:15:56 +08:00 committed by David Sterba
parent 133e4520ea
commit 0db197d8b2

View 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_fs_info *fs_info = root->fs_info;
struct btrfs_trans_handle *h = malloc(sizeof(*h)); struct btrfs_trans_handle *h = malloc(sizeof(*h));
BUG_ON(!h);
BUG_ON(root->commit_root); BUG_ON(root->commit_root);
BUG_ON(fs_info->running_transaction); BUG_ON(fs_info->running_transaction);
fs_info->running_transaction = h; fs_info->running_transaction = h;