From patchwork Wed Dec 21 15:03:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Stein X-Patchwork-Id: 9483165 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DC240600CA for ; Wed, 21 Dec 2016 15:08:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC9DD283FC for ; Wed, 21 Dec 2016 15:08:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C07BB2841B; Wed, 21 Dec 2016 15:08:24 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6DD6B283FC for ; Wed, 21 Dec 2016 15:08:24 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cJiRR-0002Bf-KZ; Wed, 21 Dec 2016 15:04:29 +0000 Received: from webbox1416.server-home.net ([77.236.96.61]) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cJiRC-0001wu-Km for linux-arm-kernel@lists.infradead.org; Wed, 21 Dec 2016 15:04:15 +0000 Received: from imapserver.systec-electronic.com (unknown [212.185.67.146]) by webbox1416.server-home.net (Postfix) with ESMTPA id 0CEE227A6E7; Wed, 21 Dec 2016 16:03:57 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by imapserver.systec-electronic.com (Postfix) with ESMTP id 0DF27DA0A41; Wed, 21 Dec 2016 16:03:57 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at imapserver.systec-electronic.com Received: from imapserver.systec-electronic.com ([127.0.0.1]) by localhost (imapserver.systec-electronic.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 552WAL44A5z0; Wed, 21 Dec 2016 16:03:51 +0100 (CET) Received: from localhost.localdomain (ws-stein.systec.local [192.168.10.118]) by imapserver.systec-electronic.com (Postfix) with ESMTP id 8489FDA0A54; Wed, 21 Dec 2016 16:03:51 +0100 (CET) From: Alexander Stein To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Will Deacon , Mark Rutland , Russell King Subject: [PATCH v2 1/2] drivers/perf: arm_pmu: Use devm_ allocators Date: Wed, 21 Dec 2016 16:03:39 +0100 Message-Id: <20161221150340.25657-2-alexander.stein@systec-electronic.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161221150340.25657-1-alexander.stein@systec-electronic.com> References: <20161221150340.25657-1-alexander.stein@systec-electronic.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161221_070414_909060_C60A06D3 X-CRM114-Status: GOOD ( 11.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Alexander Stein MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This eliminates several calls to kfree. Signed-off-by: Alexander Stein --- drivers/perf/arm_pmu.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c index b37b572..a9bbdbf 100644 --- a/drivers/perf/arm_pmu.c +++ b/drivers/perf/arm_pmu.c @@ -917,7 +917,8 @@ static int of_pmu_irq_cfg(struct arm_pmu *pmu) bool using_spi = false; struct platform_device *pdev = pmu->plat_device; - irqs = kcalloc(pdev->num_resources, sizeof(*irqs), GFP_KERNEL); + irqs = devm_kcalloc(&pdev->dev, pdev->num_resources, sizeof(*irqs), + GFP_KERNEL); if (!irqs) return -ENOMEM; @@ -939,7 +940,6 @@ static int of_pmu_irq_cfg(struct arm_pmu *pmu) pr_err("PPI/SPI IRQ type mismatch for %s!\n", dn->name); of_node_put(dn); - kfree(irqs); return -EINVAL; } @@ -988,10 +988,8 @@ static int of_pmu_irq_cfg(struct arm_pmu *pmu) int ret; ret = irq_get_percpu_devid_partition(irq, &pmu->supported_cpus); - if (ret) { - kfree(irqs); + if (ret) return ret; - } } else { /* Otherwise default to all CPUs */ cpumask_setall(&pmu->supported_cpus); @@ -1001,8 +999,6 @@ static int of_pmu_irq_cfg(struct arm_pmu *pmu) /* If we matched up the IRQ affinities, use them to route the SPIs */ if (using_spi && i == pdev->num_resources) pmu->irq_affinity = irqs; - else - kfree(irqs); return 0; } @@ -1017,7 +1013,7 @@ int arm_pmu_device_probe(struct platform_device *pdev, struct arm_pmu *pmu; int ret = -ENODEV; - pmu = kzalloc(sizeof(struct arm_pmu), GFP_KERNEL); + pmu = devm_kzalloc(&pdev->dev, sizeof(struct arm_pmu), GFP_KERNEL); if (!pmu) { pr_info("failed to allocate PMU device!\n"); return -ENOMEM; @@ -1074,8 +1070,6 @@ int arm_pmu_device_probe(struct platform_device *pdev, out_free: pr_info("%s: failed to register PMU devices!\n", of_node_full_name(node)); - kfree(pmu->irq_affinity); - kfree(pmu); return ret; }