diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index ca47f7c43ee6..b7a7a94f041d 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -7229,6 +7229,14 @@ noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len, goto out; } + /* + * We don't need the path anymore, plus through the csum_exist_in_range() + * call below we will end up allocating another path. So free the path + * to avoid unnecessary extra memory usage. + */ + btrfs_free_path(path); + path = NULL; + /* * adjust disk_bytenr and num_bytes to cover just the bytes * in this extent we are about to write. If there