Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1664203rwb; Mon, 7 Nov 2022 04:29:48 -0800 (PST) X-Google-Smtp-Source: AMsMyM4Ys2ACHN+r/43WXA6nPQiQGrziALt3IUO6K3AsAT0HfTr6Y+5cVP67ddJGqJV6HcYn/uEd X-Received: by 2002:a05:6402:1497:b0:462:c929:7e89 with SMTP id e23-20020a056402149700b00462c9297e89mr51045813edv.149.1667824188307; Mon, 07 Nov 2022 04:29:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667824188; cv=none; d=google.com; s=arc-20160816; b=FLtzcfxlibSITw6p7Lm7aiOsbvZJr5oahzDBTEuMmi7lAcjcmoOWsVuIQPQR/lMD+1 SYe6NjhyBtU09kOnmNkaXpPkcDuGmNIS7d0mRn7m1NclnYoUFaMyXNLhhvyYUplENIoj 9wi13QXLB2kBXFLp2S30Vo+iE0orQia/hSHXk/kBRMnk5lhZAndNwK9wlxwU7y+olTMD 7VPWur8bEgBUFfJ+ix5nTUTGcqvQKEmffhmWpjF8qwb1eR7vsU+DGlJHWa5EMZWLCl9v DzLmnZN5dXQXuPgfXkxGFIVVqWO4GIC3sb1FPGadFRQyUFxdJtdqoU4bcnya6NWC6UTH OdJw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2EkOIBNA7D1BIBwaIa8nmWutEc3lXF7Ye4dNCdSq3Zo=; b=0dOjSTKWJ+nUaGB37KuArsTnLzsA9nWUj8WlfGUUd1JiRwA0rvQ3hKtbECyZdU/pVj W8oeetOmm46Ts9w4nLRl++oBirl7ZzM8Rbftq+sLztab0yYk4bceerW+QbOKqIwPfoOl Jjr595l83wfWnBYEfK2cyij2RmJddmK+ExuCBJviGqlm2nsegdfE9JPkOUMqqfE0JLiL B6yVyOTHkmlDYAUzWJgGm11VhnTkU9PdQRDXQTjPBOhzqosEhIcpYnLs70U1YaOpnE7I WYPYdRgB4IIS9Bma1Av6iFbN6emkiwR2MREvnetKuksK8AYomtvHyximwZuGw1GAub37 XIgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Vb0c3YYy; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mp23-20020a1709071b1700b00782a5657512si10192939ejc.416.2022.11.07.04.29.24; Mon, 07 Nov 2022 04:29:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-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=@gmail.com header.s=20210112 header.b=Vb0c3YYy; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232278AbiKGM2x (ORCPT + 99 others); Mon, 7 Nov 2022 07:28:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232286AbiKGM2q (ORCPT ); Mon, 7 Nov 2022 07:28:46 -0500 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19C11A186 for ; Mon, 7 Nov 2022 04:28:45 -0800 (PST) Received: by mail-pf1-x431.google.com with SMTP id k22so10458988pfd.3 for ; Mon, 07 Nov 2022 04:28:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2EkOIBNA7D1BIBwaIa8nmWutEc3lXF7Ye4dNCdSq3Zo=; b=Vb0c3YYyinSpocRDLeVPm3+j8BuhZZnwThaJg/Z3YlgMVJl7H0v49qd497i8qvoEix 5cpnYrTqYBoqgJZQEgUU1kPg3/JHW9/qR8rudacymuNcnM4NmfZpkGgNM42wPYChKGUw OTmqWqdkQN3WARXBcH8ZIRxK39E3XRQIbCxYGgFi3YWiotuc35kGDeTf/Fw3a6Hd0Kmv 13bcMeGkLltdAqXOY6IVPl3K63HoPAbDUf5rRidvFE+yibPUMreHt1ZH72go9QBElKaJ qvSkAiRoUMab/5UEDl0hITwnldwGTEagAkEnT03OHNUoWI1smQvKPESAmiNlTiLMmCVm vevA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2EkOIBNA7D1BIBwaIa8nmWutEc3lXF7Ye4dNCdSq3Zo=; b=ElN05yQWIRURD9z78IGcWDeO1VogHICA6t32QXM3iyvBXEQ0E4kjz5fcuDlFta9kws vtGzX89pHVgo3fn2w7yMxrx50KQCONsplHTnwNT/yJOqBYvcN7lhmHHHTxZauWQmd/mX KaQG2wk41MDEK8FFdO+GKevvG2C99gGplwhqb5WvxZAJ/1W57HOY4+2dIYenmYjaPmsh xRYPdR/vypTGYx8PGUKaRfoYvPLLPHZuM7VfX8CkfUSCTzp8bcpVIaq1vIdgyfGj+XXL A+hpoFpqSJSl4VdydkY26w/DLlZyoqEzNS1n3btQRflZQumpBZFtCumx33XMawRR9qjE SALA== X-Gm-Message-State: ANoB5pm0NTFFuF4j0u2nwyh5kHmeba7EJCWoHq49WKiW5y9gHOYuBoOO NFie0eF54p4eZ5tN3q+v0ZIhPZVcn8E= X-Received: by 2002:a63:e50d:0:b0:470:60a4:892b with SMTP id r13-20020a63e50d000000b0047060a4892bmr8384190pgh.148.1667824124613; Mon, 07 Nov 2022 04:28:44 -0800 (PST) Received: from localhost ([2406:7400:63:f20b:312d:45b2:85c1:c486]) by smtp.gmail.com with ESMTPSA id c18-20020a63ea12000000b00462255f5aeasm4128183pgi.40.2022.11.07.04.28.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Nov 2022 04:28:43 -0800 (PST) From: "Ritesh Harjani (IBM)" To: Theodore Ts'o Cc: linux-ext4@vger.kernel.org, Harshad Shirwadkar , Wang Shilong , Andreas Dilger , Li Xi , Ritesh Harjani Subject: [RFCv1 62/72] e2fsck: fix memory leaks with pfsck enabled Date: Mon, 7 Nov 2022 17:51:50 +0530 Message-Id: <1a72168b983a877458d5fc20409620df31b6a619.1667822612.git.ritesh.list@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,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: X-Mailing-List: linux-ext4@vger.kernel.org From: Wang Shilong valgrind detected two memory leaks: 1) quota context is not released after merging. 2) @refcount_orig should be released Signed-off-by: Wang Shilong Signed-off-by: Ritesh Harjani (IBM) --- e2fsck/e2fsck.c | 4 ++++ e2fsck/pass1.c | 1 + 2 files changed, 5 insertions(+) diff --git a/e2fsck/e2fsck.c b/e2fsck/e2fsck.c index 53af8905..db0a5059 100644 --- a/e2fsck/e2fsck.c +++ b/e2fsck/e2fsck.c @@ -106,6 +106,10 @@ errcode_t e2fsck_reset_context(e2fsck_t ctx) ea_refcount_free(ctx->refcount_extra); ctx->refcount_extra = 0; } + if (ctx->refcount_orig) { + ea_refcount_free(ctx->refcount_orig); + ctx->refcount_orig = 0; + } if (ctx->ea_block_quota_blocks) { ea_refcount_free(ctx->ea_block_quota_blocks); ctx->ea_block_quota_blocks = 0; diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c index ed4275c3..d745699d 100644 --- a/e2fsck/pass1.c +++ b/e2fsck/pass1.c @@ -3039,6 +3039,7 @@ static int e2fsck_pass1_thread_join(e2fsck_t global_ctx, e2fsck_t thread_ctx) retval = e2fsck_pass1_merge_context(global_ctx, thread_ctx); + quota_release_context(&thread_ctx->qctx); /* * @block_metadata_map and @block_dup_map are * shared, so we don't free them. -- 2.37.3