From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48F76CA9EAF for ; Sun, 27 Oct 2019 21:31:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 18AB820717 for ; Sun, 27 Oct 2019 21:31:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572211890; bh=URbgeZQaqquP9A2/7giNDQDe/iVln+oZ/NrCDciY/wI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=JE7JzTZOr3bMBApifAfH6xnxU88NcTdeeOvEYXZBBp+8vAcxp6MGaYORgs9B9UFNc ufwsTYNpBqyQh/LseqJu0I28kU1TN8U2bqpzEgv0twK6tpx+ULgdg9RuXX4g4NosrH bSGA5XhaWUclvIu3mRMAYOV4JOqRsU9sJLq1vzf4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730981AbfJ0VRH (ORCPT ); Sun, 27 Oct 2019 17:17:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:36920 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730954AbfJ0VRH (ORCPT ); Sun, 27 Oct 2019 17:17:07 -0400 Received: from localhost (100.50.158.77.rev.sfr.net [77.158.50.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 17D51205C9; Sun, 27 Oct 2019 21:17:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572211026; bh=URbgeZQaqquP9A2/7giNDQDe/iVln+oZ/NrCDciY/wI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mQ8qUUAhEIy533zBmhsR79rs8RC/5QBg78xct48LSV7BHTz92IXu2Lp0jt6MqsQeE jUlJOQADt1ZIjetrENENN8cOY6m6dCdaaI4tQCH+oBtZIH18wk2dcAsZYYP2KfGnGY ZHmGrOKVlXd1TQjjA4S1LZqapZESmot4E7VDZHkE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Anand Jain , Johannes Thumshirn , Qu Wenruo , David Sterba Subject: [PATCH 4.19 84/93] btrfs: block-group: Fix a memory leak due to missing btrfs_put_block_group() Date: Sun, 27 Oct 2019 22:01:36 +0100 Message-Id: <20191027203314.029888282@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191027203251.029297948@linuxfoundation.org> References: <20191027203251.029297948@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Qu Wenruo commit 4b654acdae850f48b8250b9a578a4eaa518c7a6f upstream. In btrfs_read_block_groups(), if we have an invalid block group which has mixed type (DATA|METADATA) while the fs doesn't have MIXED_GROUPS feature, we error out without freeing the block group cache. This patch will add the missing btrfs_put_block_group() to prevent memory leak. Note for stable backports: the file to patch in versions <= 5.3 is fs/btrfs/extent-tree.c Fixes: 49303381f19a ("Btrfs: bail out if block group has different mixed flag") CC: stable@vger.kernel.org # 4.9+ Reviewed-by: Anand Jain Reviewed-by: Johannes Thumshirn Signed-off-by: Qu Wenruo Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/extent-tree.c | 1 + 1 file changed, 1 insertion(+) --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -10000,6 +10000,7 @@ int btrfs_read_block_groups(struct btrfs btrfs_err(info, "bg %llu is a mixed block group but filesystem hasn't enabled mixed block groups", cache->key.objectid); + btrfs_put_block_group(cache); ret = -EINVAL; goto error; }