Skip to content

Commit

Permalink
Btrfs: check return value of ulist_alloc() properly
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Tsutomu Itoh authored and Chris Mason committed Oct 1, 2012
1 parent f54fb85 commit 3d6b5c3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions fs/btrfs/qgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))) {
Expand Down Expand Up @@ -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))) {
Expand Down

0 comments on commit 3d6b5c3

Please sign in to comment.