Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp2156736rwn; Fri, 9 Sep 2022 09:15:22 -0700 (PDT) X-Google-Smtp-Source: AA6agR6i4EsDVpONe3oYD36OuhJ1mWeFSvpMbW8jcFrrPAoaKkjdHJzbhz3KIr9CrNK26Vgfqnb7 X-Received: by 2002:a17:902:f541:b0:176:e8f1:cd57 with SMTP id h1-20020a170902f54100b00176e8f1cd57mr13432884plf.8.1662740121810; Fri, 09 Sep 2022 09:15:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662740121; cv=none; d=google.com; s=arc-20160816; b=wKmbVVPzUX7eesZN0FPPfqZSNUITO4A3/lkb3XFnj6hACwGK5ZwCDHDwySOow3NqxN xyryoFzXiwfLP1PQle0L3elffjzuxugq+rP0B+tRE1XyiKghheIJ0VA4p5rsWOWGdh+D xZuts40r5YvOT+5QDMDhX09iLFzLnRdGQRMWbPCNxyEp0aD7ihLjzq/cqRsSLxGmGotH Jnh+u6tYtYgh2mnzXeiH1pC/P0xMiLfc925+NjcZVbrL7+A9pR6SkSdwdevsIFczXNLw TIEDloWGlLNyNWgSRa0h47oDMakzerLWWMw7FXzFPdQGhZhC8g0DeZ4i03usfLtVDVlq xRbQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=X+Q+XxogE2IjpyqqxHb1Rmob5mxFBfelVSRSDl23U/0=; b=cL47c4wf7HLBg5J92+is91N3ISze45PBwTORGgLoNgQ2AIKWmE8vZH1WwwWHHX9vuL fWQLG8hChevZ05AOxH1ktb1MmTMtkqkrVjvmf91DrjXT7ch1uH9HW5B7SzVKCUs+sKDX 2hCcWrsIE+nfHr80vFLXL6vzKbuhRZ2RszY1xTHCm53JcCtWeMUqXyH9BhwYrCwIkOoM 7u6xbrclgxNQ5S9AGFfw11EKVIHiKzyN2KG3EBfM8aePrFAV9zrgcamSHyHkD83exel/ jUwCvTsz8lf3N4pijYizXz4YPRwlTn+NbFjhPPi6J6AWnQpwJS/BSc8Sq9R1O82+vtEd np8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="MYeKp/my"; 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=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 j190-20020a638bc7000000b004388f47a0b1si523973pge.572.2022.09.09.09.15.09; Fri, 09 Sep 2022 09:15:21 -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; dkim=pass header.i=@gmail.com header.s=20210112 header.b="MYeKp/my"; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232468AbiIIPgG (ORCPT + 99 others); Fri, 9 Sep 2022 11:36:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232394AbiIIPfZ (ORCPT ); Fri, 9 Sep 2022 11:35:25 -0400 Received: from mail-oa1-x33.google.com (mail-oa1-x33.google.com [IPv6:2001:4860:4864:20::33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A60AFA186; Fri, 9 Sep 2022 08:34:40 -0700 (PDT) Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-1274ec87ad5so4906840fac.0; Fri, 09 Sep 2022 08:34:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=X+Q+XxogE2IjpyqqxHb1Rmob5mxFBfelVSRSDl23U/0=; b=MYeKp/my9+idmuuuAX6U7MZeK78ZVnmx7OyeIejkqZ3YQbcjeX7m3fkstN56N7E/tj mYutp3pu5pBxRCvAfYMCu4xh+JQFwoQgxDCQfDliBbxH+NaRLjtVMLYoV3obdai585Xi zGUUYoVVwagneWDIVNlE9hhrNLl6H8ePxIXq6ZFS0zXwc8JvXPfXJILOozJc8JFZKUdR IcpanS+kbRJfFxUbLalKuNiptKenxQKKfMjeidH/9PXRCo3aAjjrB9BmBmXzWPEWoYUv K6LAcUdbHOP9Xhw5mlPXhk++L7SazZHMM4d6rk7kwnsnA6tTB+2hyJG+rnWZPX8bsn3s TpGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=X+Q+XxogE2IjpyqqxHb1Rmob5mxFBfelVSRSDl23U/0=; b=8NhpscRFUKxxSL3L1hHrQNafbIf3saqWg+lLAW11WX3zT+ZJTPoUCYlkTekyAxSJGS JFfj30E5rx3Jy6L7s1P/sBGivdlxaw+MT+4E1foh3YWds9Yp4YUVBxFMf2ZRfWlzEnIh 6HZwYBWYlh3wQLaPWPCKJpMDjRBFX23voLtKfftC7CiiF2q9OGyFpfx1taqdLwpdhZB9 tvtDGkLZAxvHnzTAwJDF5ZOaqjk0Y666UFjfCHDXCjTLP6WFjPU+qFkbHw6/pulrwBfh Pcz2l1N0rgTfJUy3PLfVX96a4/Yzr8RRqkACWZvZXessp4cUjjOzGBGObaEMAUSx8Ds3 VBgA== X-Gm-Message-State: ACgBeo1u4zPWy0L0JmljGgHhUYd561evVatHLvujWdsWPpQcRzjHtCEp oVSeHwoVNJzy8xuUwgUldR8= X-Received: by 2002:a05:6808:152b:b0:343:ef9d:4729 with SMTP id u43-20020a056808152b00b00343ef9d4729mr3926178oiw.286.1662737625456; Fri, 09 Sep 2022 08:33:45 -0700 (PDT) Received: from macondo.. ([2804:431:e7cc:ed0b:fde6:d0df:8e59:d84f]) by smtp.gmail.com with ESMTPSA id l4-20020aca1904000000b00344851ea0ddsm351759oii.56.2022.09.09.08.33.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Sep 2022 08:33:45 -0700 (PDT) From: Rafael Mendonca To: "Rafael J. Wysocki" , Len Brown , Sudeep Holla Cc: Rafael Mendonca , "Rafael J. Wysocki" , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] ACPI: PCC: Release resources on address space setup failure path Date: Fri, 9 Sep 2022 12:33:19 -0300 Message-Id: <20220909153320.501347-1-rafaelmendsr@gmail.com> X-Mailer: git-send-email 2.34.1 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,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 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(). Also, the PCC mailbox channel doesn't get freed under an error path in acpi_os_ioremap(). Fixes: 77e2a04745ff8 ("ACPI: PCC: Implement OperationRegion handler for the PCC Type 3 subtype") Signed-off-by: Rafael Mendonca --- v1->v2 - Add PCC mailbox channel release to the unwind path - Update commit msg to reflect the addition of the mailbox free --- drivers/acpi/acpi_pcc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/acpi/acpi_pcc.c b/drivers/acpi/acpi_pcc.c index a12b55d81209..84f1ac416b57 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,8 @@ 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); + pcc_mbox_free_channel(data->pcc_chan); + kfree(data); return AE_NO_MEMORY; } -- 2.34.1