Patch "btrfs: fix extent map leak in unexpected scenario at unpin_extent_cache()" has been added to the 6.8-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    btrfs: fix extent map leak in unexpected scenario at unpin_extent_cache()

to the 6.8-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     btrfs-fix-extent-map-leak-in-unexpected-scenario-at-.patch
and it can be found in the queue-6.8 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 8d619ded0caaaca65facceea8842dfc41e3370b7
Author: Filipe Manana <fdmanana@xxxxxxxx>
Date:   Wed Mar 13 11:37:31 2024 +0000

    btrfs: fix extent map leak in unexpected scenario at unpin_extent_cache()
    
    [ Upstream commit 8a565ec04d6c43f330e7401e5af3458431b29bc6 ]
    
    At unpin_extent_cache() if we happen to find an extent map with an
    unexpected start offset, we jump to the 'out' label and never release the
    reference we added to the extent map through the call to
    lookup_extent_mapping(), therefore resulting in a leak. So fix this by
    moving the free_extent_map() under the 'out' label.
    
    Fixes: c03c89f821e5 ("btrfs: handle errors returned from unpin_extent_cache()")
    Reviewed-by: Qu Wenruo <wqu@xxxxxxxx>
    Reviewed-by: Anand Jain <anand.jain@xxxxxxxxxx>
    Signed-off-by: Filipe Manana <fdmanana@xxxxxxxx>
    Reviewed-by: David Sterba <dsterba@xxxxxxxx>
    Signed-off-by: David Sterba <dsterba@xxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/btrfs/extent_map.c b/fs/btrfs/extent_map.c
index c02039db5d247..76378382dd8c4 100644
--- a/fs/btrfs/extent_map.c
+++ b/fs/btrfs/extent_map.c
@@ -342,9 +342,9 @@ int unpin_extent_cache(struct btrfs_inode *inode, u64 start, u64 len, u64 gen)
 		em->mod_len = em->len;
 	}
 
-	free_extent_map(em);
 out:
 	write_unlock(&tree->lock);
+	free_extent_map(em);
 	return ret;
 
 }




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux