Message ID | 9a1d857866d4768090d7f89869076b7a5a85116b.1670875295.git.christophe.jaillet@wanadoo.fr |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2442320wrr; Mon, 12 Dec 2022 12:09:29 -0800 (PST) X-Google-Smtp-Source: AA0mqf5Mr+DnC08QHRL2rEi3cEGRNpWEY21YOBBCrINkiLwma8euCKdrhUVxMdfzu84ImrRiDKyX X-Received: by 2002:a05:6402:1458:b0:46b:7706:652a with SMTP id d24-20020a056402145800b0046b7706652amr1915828edx.27.1670875769462; Mon, 12 Dec 2022 12:09:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670875769; cv=none; d=google.com; s=arc-20160816; b=wM14TBcbDscq1ykHWY8KqMwh/KZ+w9qamkvBfFTqIZbIrNE+aU21jPA3SXFLBMoufH 4r9JJvIgLOzkYCwDYskvR9c4u2O+fgaMGHGEmYf7qAdr3hO1j5tVPYNRoQYezTLTWgXd 89y+8wcDY7avGjgKQE4+lx/DfB9qO7daP6HY7G9Hr2ill0Z8TD1KYE2IBpono+NOi7o+ jDyL/PtU3r/Z2REz281ImchstFx+jsTmBnDhAOQNI2v4Vq79x+t358NChz8HjK6OD+FS VuBnrQZXVsSiu1Tx2P3XDgxxchNPF9SqDZwVpxKvFiOfNkKxpNArZhxSSqgkhAuNIRLv Jm+A== 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=+DB6eQoa66t+Q8xvZ/ocgyeWiwBAppQcWNDXZshaZAU=; b=SMfdfLWJMtY5n2JpWkTT8Uf/8R8HRFkO3/T42CtXYO9uHtY39kRCXlxFYzt30cTbFz 77QykHWel4BbmAJQG1SqxJ2r+bwpQ+ox1TPpdvnGt7mpGC6/hXuXh6yelfGdcqJXfQyy MmnrC+x06mMbPQfjOD15KtCNuy+S3ex1Y1+qONgEag5jEjan2kQOmS6ah07kOWTlsQgI DNMBDoG9j3XBQ3TR7UO5gqsYVlzEio9GFaD+lopdNWgGts25KxDStQrzvbDKQCQ4TxMe jSLaoZ3eDQAK6lnsSNUojCyHdJqVwhefmHCh6yIvGRx+WlcdXC4iSatSpTehjfrHL+Ax V6lg== 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 t9-20020a50ab49000000b0046b7d1b9d79si7985706edc.328.2022.12.12.12.09.05; Mon, 12 Dec 2022 12:09:29 -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 S232867AbiLLUBv (ORCPT <rfc822;jeantsuru.cumc.mandola@gmail.com> + 99 others); Mon, 12 Dec 2022 15:01:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232994AbiLLUBu (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 12 Dec 2022 15:01:50 -0500 Received: from smtp.smtpout.orange.fr (smtp-16.smtpout.orange.fr [80.12.242.16]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CB7517588 for <linux-kernel@vger.kernel.org>; Mon, 12 Dec 2022 12:01:49 -0800 (PST) Received: from pop-os.home ([86.243.100.34]) by smtp.orange.fr with ESMTPA id 4ozhpgCRi0H6I4ozhpkHYh; Mon, 12 Dec 2022 21:01:47 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Mon, 12 Dec 2022 21:01:47 +0100 X-ME-IP: 86.243.100.34 From: Christophe JAILLET <christophe.jaillet@wanadoo.fr> To: Chris Mason <clm@fb.com>, Josef Bacik <josef@toxicpanda.com>, David Sterba <dsterba@suse.com> Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET <christophe.jaillet@wanadoo.fr>, Chris Mason <chris.mason@oracle.com>, linux-btrfs@vger.kernel.org Subject: [PATCH] btrfs: Fix an error handling path in btrfs_defrag_leaves() Date: Mon, 12 Dec 2022 21:01:43 +0100 Message-Id: <9a1d857866d4768090d7f89869076b7a5a85116b.1670875295.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752040230925171280?= X-GMAIL-MSGID: =?utf-8?q?1752040230925171280?= |
Series |
btrfs: Fix an error handling path in btrfs_defrag_leaves()
|
|
Commit Message
Christophe JAILLET
Dec. 12, 2022, 8:01 p.m. UTC
All error handling paths end to 'out', except this memory allocation
failure.
This is spurious. So branch to the error handling path also in this case.
It will add a call to:
memset(&root->defrag_progress, 0,
sizeof(root->defrag_progress));
Fixes: 6702ed490ca0 ("Btrfs: Add run time btree defrag, and an ioctl to force btree defrag")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
This patch is completely speculative.
Review with care !
---
fs/btrfs/defrag.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
Comments
On Mon, Dec 12, 2022 at 09:01:43PM +0100, Christophe JAILLET wrote: > All error handling paths end to 'out', except this memory allocation > failure. > > This is spurious. So branch to the error handling path also in this case. > It will add a call to: > memset(&root->defrag_progress, 0, > sizeof(root->defrag_progress)); > > Fixes: 6702ed490ca0 ("Btrfs: Add run time btree defrag, and an ioctl to force btree defrag") > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > --- > This patch is completely speculative. > > Review with care ! I think it's correct, using goto for cleanup is for consistency and the memset is not necessary on error paths but again for consistency with what other types of errors in the functions lead to. Added to misc-next, thanks.
diff --git a/fs/btrfs/defrag.c b/fs/btrfs/defrag.c index 0a3c261b69c9..d81b764a7644 100644 --- a/fs/btrfs/defrag.c +++ b/fs/btrfs/defrag.c @@ -358,8 +358,10 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans, goto out; path = btrfs_alloc_path(); - if (!path) - return -ENOMEM; + if (!path) { + ret = -ENOMEM; + goto out; + } level = btrfs_header_level(root->node);