mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-02-22 00:39:33 -05:00
xfs: check for dead buffers in xfs_buf_find_insert
Commit32dd4f9c50("xfs: remove a superflous hash lookup when inserting new buffers") converted xfs_buf_find_insert to use rhashtable_lookup_get_insert_fast and thus an operation that returns the existing buffer when an insert would duplicate the hash key. But this code path misses the check for a buffer with a reference count of zero, which could lead to reusing an about to be freed buffer. Fix this by using the same atomic_inc_not_zero pattern as xfs_buf_insert. Fixes:32dd4f9c50("xfs: remove a superflous hash lookup when inserting new buffers") Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Cc: stable@vger.kernel.org # v6.0 Signed-off-by: Carlos Maiolino <cem@kernel.org>
This commit is contained in:
committed by
Carlos Maiolino
parent
4e35be63c4
commit
07eae0fa67
@@ -655,9 +655,8 @@ xfs_buf_find_insert(
|
||||
spin_unlock(&bch->bc_lock);
|
||||
goto out_free_buf;
|
||||
}
|
||||
if (bp) {
|
||||
if (bp && atomic_inc_not_zero(&bp->b_hold)) {
|
||||
/* found an existing buffer */
|
||||
atomic_inc(&bp->b_hold);
|
||||
spin_unlock(&bch->bc_lock);
|
||||
error = xfs_buf_find_lock(bp, flags);
|
||||
if (error)
|
||||
|
||||
Reference in New Issue
Block a user