diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2021-11-13 12:57:00 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:16 -0400 |
commit | 496b7238794ac9209c68fba3592b59576140fa55 (patch) | |
tree | e6f7a2d4e50b0db48a6294887163f0e3bf162f5e /fs/bcachefs/dirent.c | |
parent | 54b2db3d58eadb4496a671d43b1e7c0506dd0220 (diff) | |
download | linux-496b7238794ac9209c68fba3592b59576140fa55.tar.gz linux-496b7238794ac9209c68fba3592b59576140fa55.tar.bz2 linux-496b7238794ac9209c68fba3592b59576140fa55.zip |
bcachefs: Fix an exiting of uninitialized iterator
bch2_dirent_lookup had an error path where we'd exit a btree_iter that
hadn't been properly initialized.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/dirent.c')
-rw-r--r-- | fs/bcachefs/dirent.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/fs/bcachefs/dirent.c b/fs/bcachefs/dirent.c index 9267eea810f8..5db1426faaf3 100644 --- a/fs/bcachefs/dirent.c +++ b/fs/bcachefs/dirent.c @@ -418,16 +418,15 @@ int __bch2_dirent_lookup_trans(struct btree_trans *trans, k = bch2_btree_iter_peek_slot(iter); ret = bkey_err(k); - if (ret) { - bch2_trans_iter_exit(trans, iter); - return ret; - } + if (ret) + goto err; d = bkey_s_c_to_dirent(k); ret = bch2_dirent_read_target(trans, dir, d, inum); if (ret > 0) ret = -ENOENT; +err: if (ret) bch2_trans_iter_exit(trans, iter); @@ -448,10 +447,10 @@ retry: ret = __bch2_dirent_lookup_trans(&trans, &iter, dir, hash_info, name, inum, 0); - - bch2_trans_iter_exit(&trans, &iter); if (ret == -EINTR) goto retry; + if (!ret) + bch2_trans_iter_exit(&trans, &iter); bch2_trans_exit(&trans); return ret; } |