Skip to content

Commit 8e587ab

Browse files
SidongYangkdave
authored andcommitted
btrfs: ioctl: don't free iov when btrfs_encoded_read() returns -EAGAIN
Fix a bug in encoded read that mistakenly frees the iov in case btrfs_encoded_read() returns -EAGAIN assuming the structure will be reused. This can happen when when receiving requests concurrently, the io_uring subsystem does not reset the data, and the last free will happen in btrfs_uring_read_finished(). Handle the -EAGAIN error and skip freeing iov. CC: [email protected] # 6.13+ Signed-off-by: Sidong Yang <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 35fec10 commit 8e587ab

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fs/btrfs/ioctl.c

+2
Original file line numberDiff line numberDiff line change
@@ -4902,6 +4902,8 @@ static int btrfs_uring_encoded_read(struct io_uring_cmd *cmd, unsigned int issue
49024902

49034903
ret = btrfs_encoded_read(&kiocb, &data->iter, &data->args, &cached_state,
49044904
&disk_bytenr, &disk_io_size);
4905+
if (ret == -EAGAIN)
4906+
goto out_acct;
49054907
if (ret < 0 && ret != -EIOCBQUEUED)
49064908
goto out_free;
49074909

0 commit comments

Comments
 (0)