btrfs: fix for refcount leak in btrfs_do_write_iter()
PATCH 1/1 btrfs: fix for refcount leak in btrfs_do_write_iter()
The patch "btrfs: enable nowait async buffered writes" introduced a potential leak in btrfs_do_write_iter() that the count for sync_writers is increased, but not decreased.
This commit addresses this problem.
Reported-by Dan Carpenter <[email protected]>
Signed-off-by Stefan Roesch <[email protected]>
--- fs/btrfs/file.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
fs/btrfs/file.c +2 -3
@@ -2106,14 +2106,13 @@ ssize_t btrfs_do_write_iter(struct kiocb *iocb, struct iov_iter *from,*/ if (BTRFS_FS_ERROR (inode->root->fs_info))return -EROFS ; +if (encoded && (iocb->ki_flags &IOCB_NOWAIT )) +return -EOPNOTSUPP ;if (sync)atomic_inc (&inode->sync_writers);if (encoded) { -if (iocb->ki_flags &IOCB_NOWAIT ) -return -EOPNOTSUPP ; - num_written =btrfs_encoded_write (iocb, from, encoded); num_sync = encoded->len; }else if (iocb->ki_flags &IOCB_DIRECT ) {
base-commit: f76349cf41451c5c42a99f18a9163377e4b364ff
Signature · 1 line
2.30.2
Quoted 8 lines · Stefan Roesch
The patch "btrfs: enable nowait async buffered writes" introduced a potential leak in
btrfs_do_write_iter()that the count forsync_writersis increased, but not decreased.This commit addresses this problem.
Reported-by Dan Carpenter <[email protected]>Signed-off-by Stefan Roesch <[email protected]>
Folded to the patch, thanks.