diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2021-07-14 07:14:45 +0300 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-23 00:09:08 +0300 |
commit | 5468f1195dcfb9256b46484822dde31c9ec0af1e (patch) | |
tree | 445567efd454a388c9bd8933f0ce3d8914090a47 /fs/bcachefs/fs-io.c | |
parent | 996fb577fdff69b1e5a72d7ca0f152ff7bb42bc8 (diff) | |
download | linux-5468f1195dcfb9256b46484822dde31c9ec0af1e.tar.xz |
bcachefs: Fix a memory leak in the dio write path
There were some error paths where we were leaking page refs - oops.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/fs-io.c')
-rw-r--r-- | fs/bcachefs/fs-io.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/fs/bcachefs/fs-io.c b/fs/bcachefs/fs-io.c index bcf954a2394f..30c12864d537 100644 --- a/fs/bcachefs/fs-io.c +++ b/fs/bcachefs/fs-io.c @@ -1826,8 +1826,6 @@ static long bch2_dio_write_loop(struct dio_write *dio) struct bch_inode_info *inode = file_bch_inode(req->ki_filp); struct bch_fs *c = inode->v.i_sb->s_fs_info; struct bio *bio = &dio->op.wbio.bio; - struct bvec_iter_all iter; - struct bio_vec *bv; unsigned unaligned, iter_count; bool sync = dio->sync, dropped_locks; long ret; @@ -1882,8 +1880,6 @@ static long bch2_dio_write_loop(struct dio_write *dio) * bio_iov_iter_get_pages was only able to get < * blocksize worth of pages: */ - bio_for_each_segment_all(bv, bio, iter) - put_page(bv->bv_page); ret = -EFAULT; goto err; } @@ -1938,6 +1934,7 @@ loop: spin_unlock(&inode->v.i_lock); bio_release_pages(bio, false); + bio->bi_vcnt = 0; if (dio->op.error) { set_bit(EI_INODE_ERROR, &inode->ei_flags); @@ -1959,6 +1956,7 @@ err: if (dio->free_iov) kfree(dio->iter.__iov); + bio_release_pages(bio, false); bio_put(bio); /* inode->i_dio_count is our ref on inode and thus bch_fs */ |