diff options
author | Mark Fasheh <mfasheh@suse.com> | 2011-08-05 15:46:16 -0700 |
---|---|---|
committer | David Sterba <dsterba@suse.cz> | 2012-03-22 01:45:37 +0100 |
commit | 0678b61851b510ba68341dff59cd9b47e1712e91 (patch) | |
tree | e8e8199ee3929e508c42bea39a3eeb122246626c /mm/mincore.c | |
parent | be1a5564fd39fa2ca6adbb41c75fb08f96a1ffcb (diff) | |
download | linux-0678b61851b510ba68341dff59cd9b47e1712e91.tar.bz2 |
btrfs: Don't BUG_ON kzalloc error in btrfs_lookup_csums_range()
Unfortunately it isn't enough to just exit here - the kzalloc() happens in a
loop and the allocated items are added to a linked list whose head is passed
in from the caller.
To fix the BUG_ON() and also provide the semantic that the list passed in is
only modified on success, I create function-local temporary list that we add
items too. If no error is met, that list is spliced to the callers at the
end of the function. Otherwise the list will be walked and all items freed
before the error value is returned.
I did a simple test on this patch by forcing an error at the kzalloc() point
and verifying that when this hits (git clone seemed to exercise this), the
function throws the proper error. Unfortunately but predictably, we later
hit a BUG_ON(ret) type line that still hasn't been fixed up ;)
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'mm/mincore.c')
0 files changed, 0 insertions, 0 deletions