mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-04 16:25:34 +00:00
btrfs: handle empty eb->folios in num_extent_folios()
num_extent_folios() unconditionally calls folio_order() on eb->folios[0]. If that is NULL this will be a segfault. It is reasonable for it to return 0 as the number of folios in the eb when the first entry is NULL, so do that instead. Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Boris Burkov <boris@bur.io> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
bc7e097509
commit
d6fe0c69b3
1 changed files with 2 additions and 0 deletions
|
@ -298,6 +298,8 @@ static inline int __pure num_extent_pages(const struct extent_buffer *eb)
|
|||
*/
|
||||
static inline int __pure num_extent_folios(const struct extent_buffer *eb)
|
||||
{
|
||||
if (!eb->folios[0])
|
||||
return 0;
|
||||
if (folio_order(eb->folios[0]))
|
||||
return 1;
|
||||
return num_extent_pages(eb);
|
||||
|
|
Loading…
Add table
Reference in a new issue