]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
bcachefs: Add missing error checking in bch2_find_by_inum_trans()
authorKent Overstreet <kent.overstreet@gmail.com>
Fri, 25 Oct 2019 23:06:26 +0000 (19:06 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:30 +0000 (17:08 -0400)
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/inode.c

index aeae536b39f10835cddcd3c1f2591df55a611336..b0e670cc9d0f3a76c067e394da6a19ce48ad549c 100644 (file)
@@ -509,7 +509,7 @@ int bch2_inode_find_by_inum_trans(struct btree_trans *trans, u64 inode_nr,
 {
        struct btree_iter *iter;
        struct bkey_s_c k;
-       int ret = -ENOENT;
+       int ret;
 
        iter = bch2_trans_get_iter(trans, BTREE_ID_INODES,
                        POS(inode_nr, 0), BTREE_ITER_SLOTS);
@@ -517,8 +517,13 @@ int bch2_inode_find_by_inum_trans(struct btree_trans *trans, u64 inode_nr,
                return PTR_ERR(iter);
 
        k = bch2_btree_iter_peek_slot(iter);
-       if (k.k->type == KEY_TYPE_inode)
-               ret = bch2_inode_unpack(bkey_s_c_to_inode(k), inode);
+       ret = bkey_err(k);
+       if (ret)
+               return ret;
+
+       ret = k.k->type == KEY_TYPE_inode
+               ? bch2_inode_unpack(bkey_s_c_to_inode(k), inode)
+               : -ENOENT;
 
        bch2_trans_iter_put(trans, iter);