Skip to content

Commit

Permalink
XFS: Free buffer pages array unconditionally
Browse files Browse the repository at this point in the history
The code in xfs_free_buf() only attempts to free the b_pages array if the
buffer is a page cache backed or page allocated buffer. The extra log buffer
that is used when the log wraps uses pages that are allocated to a different
log buffer, but it still has a b_pages array allocated when those pages
are associated to with the extra buffer in xfs_buf_associate_memory.

Hence we need to always attempt to free the b_pages array when tearing
down a buffer, not just on buffers that are explicitly marked as page bearing
buffers. This fixes a leak detected by the kernel memory leak code.

Signed-off-by: Dave Chinner <[email protected]>
Signed-off-by: Alex Elder <[email protected]>
  • Loading branch information
dchinner authored and Alex Elder committed Dec 16, 2009
1 parent a5f9be5 commit 3fc98b1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fs/xfs/linux-2.6/xfs_buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ _xfs_buf_free_pages(
{
if (bp->b_pages != bp->b_page_array) {
kmem_free(bp->b_pages);
bp->b_pages = NULL;
}
}

Expand Down Expand Up @@ -323,9 +324,8 @@ xfs_buf_free(
ASSERT(!PagePrivate(page));
page_cache_release(page);
}
_xfs_buf_free_pages(bp);
}

_xfs_buf_free_pages(bp);
xfs_buf_deallocate(bp);
}

Expand Down

0 comments on commit 3fc98b1

Please sign in to comment.