Commit 3d6b5c3b5c0b970ce8a9d3bac6854f5c0ce0295a

Authored by Tsutomu Itoh
Committed by Chris Mason
1 parent f54fb859da

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 <t-itoh@jp.fujitsu.com>

Showing 1 changed file with 8 additions and 0 deletions Side-by-side Diff

... ... @@ -1469,6 +1469,10 @@
1469 1469 * be exceeded
1470 1470 */
1471 1471 ulist = ulist_alloc(GFP_ATOMIC);
  1472 + if (!ulist) {
  1473 + ret = -ENOMEM;
  1474 + goto out;
  1475 + }
1472 1476 ulist_add(ulist, qgroup->qgroupid, (uintptr_t)qgroup, GFP_ATOMIC);
1473 1477 ULIST_ITER_INIT(&uiter);
1474 1478 while ((unode = ulist_next(ulist, &uiter))) {
... ... @@ -1541,6 +1545,10 @@
1541 1545 goto out;
1542 1546  
1543 1547 ulist = ulist_alloc(GFP_ATOMIC);
  1548 + if (!ulist) {
  1549 + btrfs_std_error(fs_info, -ENOMEM);
  1550 + goto out;
  1551 + }
1544 1552 ulist_add(ulist, qgroup->qgroupid, (uintptr_t)qgroup, GFP_ATOMIC);
1545 1553 ULIST_ITER_INIT(&uiter);
1546 1554 while ((unode = ulist_next(ulist, &uiter))) {