From patchwork Sat Apr 6 18:17:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qian Cai X-Patchwork-Id: 10888239 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C4A2617E1 for ; Sat, 6 Apr 2019 18:18:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F6C228426 for ; Sat, 6 Apr 2019 18:18:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8087B2876E; Sat, 6 Apr 2019 18:18:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B05928426 for ; Sat, 6 Apr 2019 18:18:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726493AbfDFSR6 (ORCPT ); Sat, 6 Apr 2019 14:17:58 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:33642 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726435AbfDFSR6 (ORCPT ); Sat, 6 Apr 2019 14:17:58 -0400 Received: by mail-qk1-f195.google.com with SMTP id k189so5766694qkc.0 for ; Sat, 06 Apr 2019 11:17:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lca.pw; s=google; h=from:to:cc:subject:date:message-id; bh=WeOmR6bsjMUrYlOj6qdJ5nj8AL60jTAGWVEpYntMZVg=; b=mrXpMPIIgWApzXUKPhQnSzQe96bYBJ4fEjcVXheRtFd6yfvIIZON9Ti9NbE90ZzPKc r+bJqtBatn9iqJDYmS9l+uGgbXPCjPBkcqXNiLq1B7ApxpjSfwg48bDOYWVrB26veVFJ eLgqI/9c5FGgen0AZfP04dBGZjaZD6A8vlDrYSiAOmvdLKjVVKLkd9x3CPA9Kh2S0ZsP yP1yJK6ntiVw02ZjHtxKD/WwEpv61RRe3Dg270vhmWR4ySmraRxTyfXzjIFW3HXErQHG lRrxZrLF/nW+ZhPN6WJ/8Y/6/FPg3WHlP7Z+CEXStd+nCNvNnMa4iIK6hRGmzGqEB7GL Uogg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=WeOmR6bsjMUrYlOj6qdJ5nj8AL60jTAGWVEpYntMZVg=; b=rxNoP8VHuKFNeLEdMClj4wfYnSAZWM1ff89h6kFeP8eCPUW9/w806Bi+eqfineeO1K wjt/Oc5P6zlwErwpDn1s4HyhT7UwY4bvvXdwUIj13ljtOZLJheM/nHvwClvnedaxrpzz Bapyq6wUIhuqJVX8jRZ4OGutWquPH3H95ZDZLmSiSW0U0M3A352zqgatO2ogIBmkWDCH nQOmSYwuRHabWEQPvxHdG79DpVtKYBsg7ousHLKLDZIko1Yab/OVy3KVNR7Rj5GlT6/L L4g+xD1xqCJWpe1QWhsYxmjKTCfz6G/zU+J1UYPEZm72sM2sSqRtzZoDZ6klRjTZED2l tHRQ== X-Gm-Message-State: APjAAAWKIVxjbomxSnHTaUH1Nk1uYeBITNvERKe63j0/N9dPeJ0V3oaI o8j3EeTBiTWs9Q7xduVKoTCD1Q== X-Google-Smtp-Source: APXvYqwmIqqrcRSc6NhoPo4dm3+3yokTAMrz25Rf/vxdVBa5kWpYmXAh1FKnjKgrzHcXYWefENgh7A== X-Received: by 2002:a37:650c:: with SMTP id z12mr15961249qkb.115.1554574677396; Sat, 06 Apr 2019 11:17:57 -0700 (PDT) Received: from ovpn-120-94.rdu2.redhat.com (pool-71-184-117-43.bstnma.fios.verizon.net. [71.184.117.43]) by smtp.gmail.com with ESMTPSA id f47sm17314947qta.80.2019.04.06.11.17.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 06 Apr 2019 11:17:56 -0700 (PDT) From: Qian Cai To: rjw@rjwysocki.net, lenb@kernel.org Cc: keith.busch@intel.com, gregkh@linuxfoundation.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Qian Cai Subject: [PATCH -next] acpi/hmat: fix memory leaks in hmat_init() Date: Sat, 6 Apr 2019 14:17:04 -0400 Message-Id: <20190406181704.33574-1-cai@lca.pw> X-Mailer: git-send-email 2.17.2 (Apple Git-113) Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The commit 665ac7e92757 ("acpi/hmat: Register processor domain to its memory") introduced some memory leaks below due to it fails to release the heap memory in an error path, and then the stack __initdata memory which reference them get freed during boot renders those heap memory as leaks. unreferenced object 0xc8ff8008349e9400 (size 128): comm "swapper/0", pid 1, jiffies 4294709236 (age 48121.476s) hex dump (first 32 bytes): 00 d0 9e 34 08 80 ff 84 d8 00 43 11 00 10 ff ff ...4......C..... 00 00 00 00 ff ff ff ff 00 00 00 00 00 00 00 00 ................ backtrace: [<00000000869d4503>] __kmalloc+0x568/0x600 [<0000000070fd6afb>] alloc_memory_target+0x50/0xd8 [<00000000efa2081e>] srat_parse_mem_affinity+0x58/0x5c [<000000008bfaef74>] acpi_parse_entries_array+0x1c8/0x2c0 [<0000000022804877>] acpi_table_parse_entries_array+0x11c/0x138 [<00000000ffe9cd34>] acpi_table_parse_entries+0x7c/0xac [<00000000a7023afd>] hmat_init+0x90/0x174 [<00000000694a86c1>] do_one_initcall+0x2d8/0x5f8 [<0000000024889da9>] do_initcall_level+0x37c/0x3fc [<000000009be02908>] do_basic_setup+0x38/0x50 [<0000000037b3ac0a>] kernel_init_freeable+0x194/0x258 [<00000000f5741184>] kernel_init+0x18/0x334 [<000000007b30f423>] ret_from_fork+0x10/0x18 [<000000006c7147a8>] 0xffffffffffffffff Signed-off-by: Qian Cai --- drivers/acpi/hmat/hmat.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/hmat/hmat.c b/drivers/acpi/hmat/hmat.c index b7824a0309f7..c9b8abcf012c 100644 --- a/drivers/acpi/hmat/hmat.c +++ b/drivers/acpi/hmat/hmat.c @@ -637,7 +637,7 @@ static __init int hmat_init(void) status = acpi_get_table(ACPI_SIG_HMAT, 0, &tbl); if (ACPI_FAILURE(status)) - return 0; + goto out_free; hmat_revision = tbl->revision; switch (hmat_revision) { @@ -659,8 +659,9 @@ static __init int hmat_init(void) } hmat_register_targets(); out_put: - hmat_free_structures(); acpi_put_table(tbl); +out_free: + hmat_free_structures(); return 0; } subsys_initcall(hmat_init);