From patchwork Thu Oct 10 02:39:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 11182535 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DD27D1668 for ; Thu, 10 Oct 2019 02:39:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C82DF218AC for ; Thu, 10 Oct 2019 02:39:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732611AbfJJCjf (ORCPT ); Wed, 9 Oct 2019 22:39:35 -0400 Received: from mx2.suse.de ([195.135.220.15]:41160 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726621AbfJJCjf (ORCPT ); Wed, 9 Oct 2019 22:39:35 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 04251AF87 for ; Thu, 10 Oct 2019 02:39:34 +0000 (UTC) From: Qu Wenruo To: linux-btrfs@vger.kernel.org Subject: [PATCH v3 1/3] btrfs: block-group: Fix a memory leak due to missing btrfs_put_block_group() Date: Thu, 10 Oct 2019 10:39:26 +0800 Message-Id: <20191010023928.24586-2-wqu@suse.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191010023928.24586-1-wqu@suse.com> References: <20191010023928.24586-1-wqu@suse.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org In btrfs_read_block_groups(), if we have an invalid block group which has mixed type (DATA|METADATA) while the fs doesn't have MIX_BGS feature, we error out without freeing the block group cache. This patch will add the missing btrfs_put_block_group() to prevent memory leak. Fixes: 49303381f19a ("Btrfs: bail out if block group has different mixed flag") Signed-off-by: Qu Wenruo Reviewed-by: Anand Jain Reviewed-by: Johannes Thumshirn --- fs/btrfs/block-group.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c index bf7e3f23bba7..c906a2b6c2cf 100644 --- a/fs/btrfs/block-group.c +++ b/fs/btrfs/block-group.c @@ -1762,6 +1762,7 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info) "bg %llu is a mixed block group but filesystem hasn't enabled mixed block groups", cache->key.objectid); ret = -EINVAL; + btrfs_put_block_group(cache); goto error; }