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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D11FC001DE for ; Tue, 25 Jul 2023 11:09:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234097AbjGYLJl (ORCPT ); Tue, 25 Jul 2023 07:09:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234153AbjGYLJ0 (ORCPT ); Tue, 25 Jul 2023 07:09:26 -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 1B33E3ABD for ; Tue, 25 Jul 2023 04:08:29 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 458AA61656 for ; Tue, 25 Jul 2023 11:08:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57830C433C8; Tue, 25 Jul 2023 11:08:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1690283308; bh=4YizPSOdcxOpe26SPgmpteg0DlIe9dzzGvuk8AGEH0w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1v3VAgruh1xa78A14kXWPJdqH7YWFZA+NvMjbRas79McaxGu6wbkzA80qtQkIygHW pa7DWYFD9X7uDMwUecroCzNJ4QnHRsL4VX5nKBMoWdXAOk/BNft0cgSRFrN8ZdlVzt PKnnjUdTmITzD+F/ABhdulifCadtlLToermPanf4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Johannes Thumshirn , Anand Jain , Filipe Manana , David Sterba Subject: [PATCH 5.15 08/78] btrfs: zoned: fix memory leak after finding block group with super blocks Date: Tue, 25 Jul 2023 12:45:59 +0200 Message-ID: <20230725104451.648547994@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230725104451.275227789@linuxfoundation.org> References: <20230725104451.275227789@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Filipe Manana commit f1a07c2b4e2c473ec322b8b9ece071b8c88a3512 upstream. At exclude_super_stripes(), if we happen to find a block group that has super blocks mapped to it and we are on a zoned filesystem, we error out as this is not supposed to happen, indicating either a bug or maybe some memory corruption for example. However we are exiting the function without freeing the memory allocated for the logical address of the super blocks. Fix this by freeing the logical address. Fixes: 12659251ca5d ("btrfs: implement log-structured superblock for ZONED mode") CC: stable@vger.kernel.org # 5.10+ Reviewed-by: Johannes Thumshirn Reviewed-by: Anand Jain Signed-off-by: Filipe Manana Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/block-group.c | 1 + 1 file changed, 1 insertion(+) --- a/fs/btrfs/block-group.c +++ b/fs/btrfs/block-group.c @@ -1855,6 +1855,7 @@ static int exclude_super_stripes(struct /* Shouldn't have super stripes in sequential zones */ if (zoned && nr) { + kfree(logical); btrfs_err(fs_info, "zoned: block group %llu must not contain super block", cache->start);