From: Tsutomu Itoh Date: Thu, 6 Sep 2012 06:18:10 +0000 (-0600) Subject: Btrfs: check return value of ulist_alloc() properly X-Git-Tag: next-20121002~89^2~59 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=3d6b5c3b5c0b970ce8a9d3bac6854f5c0ce0295a;p=karo-tx-linux.git Btrfs: check return value of ulist_alloc() properly ulist_alloc() has the possibility of returning NULL. So, it is necessary to check the return value. Signed-off-by: Tsutomu Itoh --- diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index 9b707ba5c6c4..5039686df6ae 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c @@ -1469,6 +1469,10 @@ int btrfs_qgroup_reserve(struct btrfs_root *root, u64 num_bytes) * be exceeded */ ulist = ulist_alloc(GFP_ATOMIC); + if (!ulist) { + ret = -ENOMEM; + goto out; + } ulist_add(ulist, qgroup->qgroupid, (uintptr_t)qgroup, GFP_ATOMIC); ULIST_ITER_INIT(&uiter); while ((unode = ulist_next(ulist, &uiter))) { @@ -1541,6 +1545,10 @@ void btrfs_qgroup_free(struct btrfs_root *root, u64 num_bytes) goto out; ulist = ulist_alloc(GFP_ATOMIC); + if (!ulist) { + btrfs_std_error(fs_info, -ENOMEM); + goto out; + } ulist_add(ulist, qgroup->qgroupid, (uintptr_t)qgroup, GFP_ATOMIC); ULIST_ITER_INIT(&uiter); while ((unode = ulist_next(ulist, &uiter))) {