Commit 84cbe2f725f59b72fffb48ab7161e771eeee5103

Authored by Wang Shilong
Committed by Josef Bacik
1 parent 06b3a860dc

Btrfs: return ENOMEM rather than use BUG_ON when btrfs_alloc_path fails

Return ENOMEM rather trigger BUG_ON, fix it.

Signed-off-by: Wang Shilong <wangsl-fnst@cn.fujitsu.com>
Reviewed-by: Miao Xie <miaox@cn.fujitsu.com>
Reviewed-by: Zach Brown <zab@redhat.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>

Showing 1 changed file with 9 additions and 3 deletions Side-by-side Diff

... ... @@ -620,7 +620,9 @@
620 620 key.offset = qgroupid;
621 621  
622 622 path = btrfs_alloc_path();
623   - BUG_ON(!path);
  623 + if (!path)
  624 + return -ENOMEM;
  625 +
624 626 ret = btrfs_search_slot(trans, root, &key, path, 0, 1);
625 627 if (ret > 0)
626 628 ret = -ENOENT;
... ... @@ -661,7 +663,9 @@
661 663 key.offset = qgroup->qgroupid;
662 664  
663 665 path = btrfs_alloc_path();
664   - BUG_ON(!path);
  666 + if (!path)
  667 + return -ENOMEM;
  668 +
665 669 ret = btrfs_search_slot(trans, root, &key, path, 0, 1);
666 670 if (ret > 0)
667 671 ret = -ENOENT;
... ... @@ -702,7 +706,9 @@
702 706 key.offset = 0;
703 707  
704 708 path = btrfs_alloc_path();
705   - BUG_ON(!path);
  709 + if (!path)
  710 + return -ENOMEM;
  711 +
706 712 ret = btrfs_search_slot(trans, root, &key, path, 0, 1);
707 713 if (ret > 0)
708 714 ret = -ENOENT;