From patchwork Mon Dec 12 20:14:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 32524 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2445603wrr; Mon, 12 Dec 2022 12:17:05 -0800 (PST) X-Google-Smtp-Source: AA0mqf6PUzb+NU8xJTiKcKrkfAp87qUzdq0hB3ipyK7QV0Id9jqc5vQOM0E7uUxipLqPFk07IB2q X-Received: by 2002:a17:906:bccf:b0:7c1:11fd:9b98 with SMTP id lw15-20020a170906bccf00b007c111fd9b98mr15137020ejb.27.1670876225140; Mon, 12 Dec 2022 12:17:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670876225; cv=none; d=google.com; s=arc-20160816; b=A0faErIBasrK+FV6zsSakK+ue4Yiu11bZ0FhsxRrWjEaMSu1/5FHgfbj3+r/dYbMd+ HnFrqx/NpMP9dGch+8oSGeW67j2IqB2Odc10SXbehl8cr26e9tcL6uaJegn/Ti5Me7K8 wzjECNwrLcw06+ERm5UGnQ3hHS2NTlzcfIcFS9BnsFgyFCKUMiINZg4Fk/8elhTH701L P66OYJ9PxZ2vS/SKIsplT1Y194oFI/t7INq/VqkKUlSs7w1cGIr18tPugLEwCO+tBLbV wirwurwUvvRf1nG0MK520CyzFHIfjv6klxVXHB4pRibAJE1k6q339ufBp6u+EHrZ++le fvYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=lMB+kM8ITlfLqrjji56PoSlcLIKx3vAF/083joRwtbs=; b=VLx0xHBuhc68pEXVoEwkouWucRPCnJs9dSGN80aVDJnFKtdI8H7h9aaTTQ7w8osL7z hJPWjQMiOcr1c1VKUp/teS6a525pXH4DXjXtPACDxhEjD7vAo4TqkZABTnIiwMNj4V0G 82JaT0/Gxlgi+luOC2Y/11v3GVEC81gsr/OiKLrKaEqXbiT0f31qSbnISy79oEfAElL7 9WCHY7/3HIiBi4iFENM7GWiCDHn3/7RIvlthSoyDsnMoib19fgTGgBtGaNw5/vlV6pHO IZ3qGGdtxIScHgiEqvbSHywln6mAVK9UZBdPeujGRBZp6fTvlItgNsXjcOu3z+B7VzTm s1TA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g11-20020a1709065d0b00b007ad8140c60asi6991994ejt.492.2022.12.12.12.16.39; Mon, 12 Dec 2022 12:17:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233310AbiLLUPc (ORCPT + 99 others); Mon, 12 Dec 2022 15:15:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233446AbiLLUPL (ORCPT ); Mon, 12 Dec 2022 15:15:11 -0500 Received: from smtp.smtpout.orange.fr (smtp-27.smtpout.orange.fr [80.12.242.27]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5601B183B2 for ; Mon, 12 Dec 2022 12:14:22 -0800 (PST) Received: from pop-os.home ([86.243.100.34]) by smtp.orange.fr with ESMTPA id 4pBqpxCjtuZP64pBqpJBAT; Mon, 12 Dec 2022 21:14:20 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Mon, 12 Dec 2022 21:14:20 +0100 X-ME-IP: 86.243.100.34 From: Christophe JAILLET To: Chris Mason , Josef Bacik , David Sterba , Sweet Tea Dorminy Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-btrfs@vger.kernel.org Subject: [PATCH] btrfs: Fix an error handling path in btrfs_rename() Date: Mon, 12 Dec 2022 21:14:17 +0100 Message-Id: <943f0f360f221da954f5dd7f16e366d0e294ae72.1670876024.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752040708611781696?= X-GMAIL-MSGID: =?utf-8?q?1752040708611781696?= If new_whiteout_inode() fails, some resources need to be freed. Add the missing goto to the error handling path. Fixes: ab3c5c18e8fa ("btrfs: setup qstr from dentrys using fscrypt helper") Signed-off-by: Christophe JAILLET Reviewed-by: Sweet Tea Dorminy --- fs/btrfs/inode.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 8bcad9940154..2ead7b1bdbaf 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -9377,8 +9377,10 @@ static int btrfs_rename(struct user_namespace *mnt_userns, if (flags & RENAME_WHITEOUT) { whiteout_args.inode = new_whiteout_inode(mnt_userns, old_dir); - if (!whiteout_args.inode) - return -ENOMEM; + if (!whiteout_args.inode) { + ret = -ENOMEM; + goto out_fscrypt_names; + } ret = btrfs_new_inode_prepare(&whiteout_args, &trans_num_items); if (ret) goto out_whiteout_inode;