Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1709965rwn; Fri, 9 Sep 2022 02:53:43 -0700 (PDT) X-Google-Smtp-Source: AA6agR70qj4HhbRJJmtznpnEkn37aHL4KPf7zFazUXNgUshAOnXBW3kpmQlcKnA68lKbP/82g6hE X-Received: by 2002:a05:6512:3159:b0:492:d660:4dd7 with SMTP id s25-20020a056512315900b00492d6604dd7mr3830910lfi.204.1662717223153; Fri, 09 Sep 2022 02:53:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662717223; cv=none; d=google.com; s=arc-20160816; b=yqZF6RiyoelLX92EWMEk9r0Sf6My0T6GOzb0LVRxEZB0I8wiN2fO6Z+G03C+w537Ic 2PuO4Hc6bag9hkJUkJTVdDqXBJotSEIXZDNgmSrewLPHoQ+lvBesTgx2l3TU6CzdB8wM BX1RwYyRnwOM3KBstVsCqvLLUu1+kihRvaA6RNZlhNc+o3oWDk1heAVS5DTPunNVCAGD KkMz8znL+JAiWzZqmMbVTWr1te/vzrTA2k+XrRQPTTJ+itARbhJ7FPC1OR0gwrPGEtbc e6rFc4e1FcviqBLTXyDP0rX9AyMTdr2FNm+19D/EfiRTn5ff3+bwddiew+XC4W8uWyBr rdHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=Vo9r4LMG8PxhlSbzSXyib3ScUryMlgRsSurOqkcQAVo=; b=Zt3Lre2+OyNMbF+7ffGL6QbQqdRDLxbe5L/LkkWGJuBZ0Dyfw8JigQvh5MLdJn8LdJ 4RnN8tXGxPHSS33W0tr+PVAsHshjMrzdhnBxJeJ5XKFSYfMj0YqLHuZ4GNCo3XSKJ8lJ gc7zsVOFccDTwLfwLCF43C0wBgWX8TuoZpN3EXTYAJJxu6OIzE2Hp0VqsdoQOSLFec8M lZY5bAo2s1wmNXcO/uiEda34iNWJcth/1ZQPsfX5SDLskr9rgJ+FDJMyTnIu3IFUcu+h ExkwRv1Ox1UlIhHQPAZeMwQgvz4YDMGlHaTtdTNoDDe21VcfktOCsc/2mdzQZPmjH6eX GjHQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bp21-20020a056512159500b004975e440faesi33563lfb.519.2022.09.09.02.53.14; Fri, 09 Sep 2022 02:53:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229990AbiIIJt5 (ORCPT + 99 others); Fri, 9 Sep 2022 05:49:57 -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: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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-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