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 E13E6C6FA82 for ; Fri, 9 Sep 2022 09:50:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229930AbiIIJt7 (ORCPT ); Fri, 9 Sep 2022 05:49:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230489AbiIIJtt (ORCPT ); Fri, 9 Sep 2022 05:49:49 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9654EC74; Fri, 9 Sep 2022 02:49:46 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id F22DF15DB; Fri, 9 Sep 2022 02:49:52 -0700 (PDT) Received: from bogus (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A785D3F73D; Fri, 9 Sep 2022 02:49:45 -0700 (PDT) Date: Fri, 9 Sep 2022 10:49:43 +0100 From: Sudeep Holla To: Rafael Mendonca Cc: "Rafael J. Wysocki" , Len Brown , "Rafael J. Wysocki" , Sudeep Holla , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] ACPI: PCC: Fix memory leak in address space setup Message-ID: <20220909094943.7nasdznnbwmg3oeb@bogus> References: <20220909021348.472674-1-rafaelmendsr@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 08, 2022 at 11:34:12PM -0300, Rafael Mendonca wrote: > On Thu, Sep 08, 2022 at 11:13:47PM -0300, Rafael Mendonca wrote: > > The allocated memory for the pcc_data struct doesn't get freed under an > > error path in pcc_mbox_request_channel() or acpi_os_ioremap(). > > > > Fixes: 77e2a04745ff8 ("ACPI: PCC: Implement OperationRegion handler for the PCC Type 3 subtype") > > Signed-off-by: Rafael Mendonca > > --- > > drivers/acpi/acpi_pcc.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/drivers/acpi/acpi_pcc.c b/drivers/acpi/acpi_pcc.c > > index a12b55d81209..fe5ab0fdc3bf 100644 > > --- a/drivers/acpi/acpi_pcc.c > > +++ b/drivers/acpi/acpi_pcc.c > > @@ -63,6 +63,7 @@ acpi_pcc_address_space_setup(acpi_handle region_handle, u32 function, > > if (IS_ERR(data->pcc_chan)) { > > pr_err("Failed to find PCC channel for subspace %d\n", > > ctx->subspace_id); > > + kfree(data); > > return AE_NOT_FOUND; > > } > > > > @@ -72,6 +73,7 @@ acpi_pcc_address_space_setup(acpi_handle region_handle, u32 function, > > if (!data->pcc_comm_addr) { > > pr_err("Failed to ioremap PCC comm region mem for %d\n", > > ctx->subspace_id); > > I was wondering if pcc_mbox_free_channel() should be called here as well > in case of acpi_os_ioremap() failure. > Yes please. There are not modules and shouldn't matter much but it is good to have it for correctness. Thanks for finding and fixing this. Also please add the fixes tag in next version. Fixes: 77e2a04745ff ("ACPI: PCC: Implement OperationRegion handler for the PCC Type 3 subtype") -- Regards, Sudeep