Skip to content

Commit 70dd062

Browse files
author
Kent Overstreet
committed
bcachefs: Fix btree_trans leak in bch2_readahead()
Reported-by: [email protected] Signed-off-by: Kent Overstreet <[email protected]>
1 parent 5fa4214 commit 70dd062

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/bcachefs/fs-io-buffered.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,6 @@ void bch2_readahead(struct readahead_control *ractl)
257257
struct bch_inode_info *inode = to_bch_ei(ractl->mapping->host);
258258
struct bch_fs *c = inode->v.i_sb->s_fs_info;
259259
struct bch_io_opts opts;
260-
struct btree_trans *trans = bch2_trans_get(c);
261260
struct folio *folio;
262261
struct readpages_iter readpages_iter;
263262

@@ -269,6 +268,7 @@ void bch2_readahead(struct readahead_control *ractl)
269268

270269
bch2_pagecache_add_get(inode);
271270

271+
struct btree_trans *trans = bch2_trans_get(c);
272272
while ((folio = readpage_iter_peek(&readpages_iter))) {
273273
unsigned n = min_t(unsigned,
274274
readpages_iter.folios.nr -
@@ -289,10 +289,10 @@ void bch2_readahead(struct readahead_control *ractl)
289289
&readpages_iter);
290290
bch2_trans_unlock(trans);
291291
}
292+
bch2_trans_put(trans);
292293

293294
bch2_pagecache_add_put(inode);
294295

295-
bch2_trans_put(trans);
296296
darray_exit(&readpages_iter.folios);
297297
}
298298

0 commit comments

Comments
 (0)