Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp3060364rwe; Mon, 29 Aug 2022 05:18:04 -0700 (PDT) X-Google-Smtp-Source: AA6agR5BWKEVl0h598NiNkiJmdjxCCJHuAE3NLFzWLWIB0qUX+WR5r8bdOZEDAAxuygZl7rHMcmH X-Received: by 2002:a17:902:8605:b0:16b:e755:3c6e with SMTP id f5-20020a170902860500b0016be7553c6emr16257543plo.42.1661775484576; Mon, 29 Aug 2022 05:18:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661775484; cv=none; d=google.com; s=arc-20160816; b=yCSpYZIiZre9PNEmyOIFg7ppWxvp+iDlPakg8Dd9vddtVl4hTrjooHN1x+lopEBSxV vE9C1r/fNW52e1WgFjgjHJ2mNyW07Z6gAU6U6M0RjVmaO3arulKYUI3H232VMUdkUmu5 iW5EuB0tPBhb+eUcr1RRTSghwXekchan0PZvNV047LSGylMQIEQ5E3BD7e/dT0cZr9LY TSJumyMAZd5wSQiTyUfmEHiTD8MhU7ovJNIvDMe5HxOPkIC1LrJmFt5Q2JExWdTSV68p xuSeHbpOKdkBjmN39usE5jprV9yFfxk/1ImHlMvjVKCsI+ALUKRVRD9pg/TY5KqoiYaN nwjQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=p+zJednRgLTg4dK+5pzSvDEz2v0nNXMc3bHVh6iS9ng=; b=PB/C/gaxae9EKf3lC+mCEV+JR+6TWDFKk4f/ZL+0B+HcGRt9qX1HXtO41/mfrYYSBM kavh/y40MYW3pd/lePx/iRVkqZHg030x9vWTO68hkSdYa1t0EAp6SyXODXXVhdNfAEme zsxW99JS9qc9lVy+0ZWx8Tgi21xm4yoO1O8U2SnhlYYGGKZafZPEzaLWS3VzQFmJ5paI 2jEX4wOb+iFlZbfTbRgflig5Xx8z2/ZMsUNykwfXiBjp3E+9LD7bIHCTrEigTnxy8ZEs nKxHFjCdRw1c1Lg1om8Yvjv2ODGk7T2koYrJ3fU7J5z/v/gBBCr6ly4kLJSCOGlFoOrW ZQ4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XYRBgnPw; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id on17-20020a17090b1d1100b001fa5ea8e65bsi10231208pjb.19.2022.08.29.05.17.52; Mon, 29 Aug 2022 05:18:04 -0700 (PDT) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XYRBgnPw; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230074AbiH2MNJ (ORCPT + 99 others); Mon, 29 Aug 2022 08:13:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230059AbiH2MMw (ORCPT ); Mon, 29 Aug 2022 08:12:52 -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 AEE119E884; Mon, 29 Aug 2022 04:57:19 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8891961228; Mon, 29 Aug 2022 11:16:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8274FC433C1; Mon, 29 Aug 2022 11:16:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661771774; bh=R4T94vtZ3ZRvYbtdw32BSmh5FI54ZGJj12qgQnW53Xw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XYRBgnPw8NHC4+qn6A6RGO81KzkGGUd0YVpi1oNueziN4AFkpk9e7ezsTOjx+wvdP KbTIg/KWNXdgkIwRAy5ktniW0N5/OxXoNwS8GcKgQvZVqoajvTon17hVi6nTY2UnUr YLNMv9xH14++OXnJUuXF5o5vNubxVa8h5DUquO50= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Qu Wenruo , Filipe Manana , David Sterba Subject: [PATCH 5.19 094/158] btrfs: fix silent failure when deleting root reference Date: Mon, 29 Aug 2022 12:59:04 +0200 Message-Id: <20220829105813.001422562@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220829105808.828227973@linuxfoundation.org> References: <20220829105808.828227973@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Filipe Manana commit 47bf225a8d2cccb15f7e8d4a1ed9b757dd86afd7 upstream. At btrfs_del_root_ref(), if btrfs_search_slot() returns an error, we end up returning from the function with a value of 0 (success). This happens because the function returns the value stored in the variable 'err', which is 0, while the error value we got from btrfs_search_slot() is stored in the 'ret' variable. So fix it by setting 'err' with the error value. Fixes: 8289ed9f93bef2 ("btrfs: replace the BUG_ON in btrfs_del_root_ref with proper error handling") CC: stable@vger.kernel.org # 5.16+ Reviewed-by: Qu Wenruo Signed-off-by: Filipe Manana Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/root-tree.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/fs/btrfs/root-tree.c +++ b/fs/btrfs/root-tree.c @@ -349,9 +349,10 @@ int btrfs_del_root_ref(struct btrfs_tran key.offset = ref_id; again: ret = btrfs_search_slot(trans, tree_root, &key, path, -1, 1); - if (ret < 0) + if (ret < 0) { + err = ret; goto out; - if (ret == 0) { + } else if (ret == 0) { leaf = path->nodes[0]; ref = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_root_ref);