From patchwork Mon Jul 3 17:15:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13300299 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7FC38C3063F for ; Mon, 3 Jul 2023 17:15:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230473AbjGCRPu (ORCPT ); Mon, 3 Jul 2023 13:15:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230477AbjGCRPs (ORCPT ); Mon, 3 Jul 2023 13:15:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 302C8E4C for ; Mon, 3 Jul 2023 10:15:37 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A1E7B60FD6 for ; Mon, 3 Jul 2023 17:15:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8DF45C433C9 for ; Mon, 3 Jul 2023 17:15:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688404536; bh=vjz+ExGsPR7PWZe80AUws7WBxS1ydcPZlqHwIdQZNzw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=p3P34J2ksBCY8QIhEOxCAssjwIzeUW6eqji8/leTvzflX5mZ/p+XP9JAo833xjaXW ylhgPHYIHaUhfXxXBZ/BpV5VuXyspwyNbsS51TqQbqXxXUUthPdAjbWH1xSdU7Guza PE7OhBXXa0FuJve+BzP4cXKQaYiEDsFBcxlirS1nlkzMDV38b8NvHsTcITgzXZZK/H DpJPeVILIHd3+dTfJPxnN4pFVlKsbNUgfG2/1X8fyEFbDKeC0liBxyH6H3pmaDcx6S k/oHEZpkRVdMp+WIhbrWSrgt5/gvp7wUJ3tBF3qcQGLPuvdYqm73O0MjoUYmYO1e/d 9L8lLqkbNsAYQ== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH 1/2] btrfs: fix double iput() on inode after an error during orphan cleanup Date: Mon, 3 Jul 2023 18:15:30 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From: Filipe Manana At btrfs_orphan_cleanup(), if we were able to find the inode, we do an iput() on the inode, then if btrfs_drop_verity_items() succeeds and then either btrfs_start_transaction() or btrfs_del_orphan_item() fail, we do another iput() in the respective error paths, resulting in an extra iput() on the inode. Fix this by setting inode to NULL after the first iput(), as iput() ignores a NULL inode pointer argument. Fixes: a13bb2c03848 ("btrfs: add missing iputs on orphan cleanup failure") Signed-off-by: Filipe Manana Reviewed-by: Boris Burkov --- fs/btrfs/inode.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index dbbb67293e34..d919318d2498 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -3728,6 +3728,7 @@ int btrfs_orphan_cleanup(struct btrfs_root *root) if (!ret) { ret = btrfs_drop_verity_items(BTRFS_I(inode)); iput(inode); + inode = NULL; if (ret) goto out; }