]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
Btrfs: check return value of ulist_alloc() properly
authorTsutomu Itoh <t-itoh@jp.fujitsu.com>
Thu, 6 Sep 2012 06:18:10 +0000 (00:18 -0600)
committerChris Mason <chris.mason@fusionio.com>
Mon, 1 Oct 2012 19:19:14 +0000 (15:19 -0400)
ulist_alloc() has the possibility of returning NULL.
So, it is necessary to check the return value.

Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
fs/btrfs/qgroup.c

index 9b707ba5c6c424787d51caa4bd1dbd86e241ae4d..5039686df6ae8e801ed8985eb5e821a226e18855 100644 (file)
@@ -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))) {