btrfs: add missing iputs on orphan cleanup failure
authorJosef Bacik <josef@toxicpanda.com>
Tue, 7 Feb 2023 16:57:22 +0000 (11:57 -0500)
committerDavid Sterba <dsterba@suse.com>
Mon, 17 Apr 2023 16:01:13 +0000 (18:01 +0200)
We missed a couple of iput()s in the orphan cleanup failure paths, add
them so we don't get refcount errors. The iput needs to be done in the
check and not under a common label due to the way the code is
structured.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/inode.c

index 957e4d76a7b6578d59fd8f0b7d887e30d02c4e2b..5dbb4aa4b10fe71fdef234d6c6b2cf7ea9f3f4e2 100644 (file)
@@ -3691,6 +3691,7 @@ int btrfs_orphan_cleanup(struct btrfs_root *root)
                        trans = btrfs_start_transaction(root, 1);
                        if (IS_ERR(trans)) {
                                ret = PTR_ERR(trans);
+                               iput(inode);
                                goto out;
                        }
                        btrfs_debug(fs_info, "auto deleting %Lu",
@@ -3698,8 +3699,10 @@ int btrfs_orphan_cleanup(struct btrfs_root *root)
                        ret = btrfs_del_orphan_item(trans, root,
                                                    found_key.objectid);
                        btrfs_end_transaction(trans);
-                       if (ret)
+                       if (ret) {
+                               iput(inode);
                                goto out;
+                       }
                        continue;
                }