From patchwork Tue May 31 11:41:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 68925 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp1894143qge; Tue, 31 May 2016 04:42:04 -0700 (PDT) X-Received: by 10.98.12.143 with SMTP id 15mr54426267pfm.12.1464694924287; Tue, 31 May 2016 04:42:04 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f81si3100721pfd.183.2016.05.31.04.42.03; Tue, 31 May 2016 04:42:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752935AbcEaLlv (ORCPT + 30 others); Tue, 31 May 2016 07:41:51 -0400 Received: from foss.arm.com ([217.140.101.70]:58405 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751484AbcEaLlm (ORCPT ); Tue, 31 May 2016 07:41:42 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6BB6954C; Tue, 31 May 2016 04:42:10 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.215.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F2E383F246; Tue, 31 May 2016 04:41:40 -0700 (PDT) From: Julien Grall To: will.deacon@arm.com, mark.rutland@arm.com Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Julien Grall Subject: [PATCH 3/3] drivers/perf: arm_pmu: Avoid leaking pmu->irq_affinity on error Date: Tue, 31 May 2016 12:41:23 +0100 Message-Id: <1464694883-26298-4-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1464694883-26298-1-git-send-email-julien.grall@arm.com> References: <1464694883-26298-1-git-send-email-julien.grall@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org pmu->irq_affinity will not be freed if an error occurred within arm_pmu_device_probe after of_pmu_irq_cfg has been called. Note that in the case of_pmu_irq_cfg is returning an error, pmu->irq_affinity will not be set, but it should be NULL as pmu was kzalloc'd. Therefore the result kfree(NULL) is benign. Signed-off-by: Julien Grall Acked-by: Mark Rutland --- drivers/perf/arm_pmu.c | 1 + 1 file changed, 1 insertion(+) -- 1.9.1 diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c index 95614d2..1b8304e 100644 --- a/drivers/perf/arm_pmu.c +++ b/drivers/perf/arm_pmu.c @@ -1040,6 +1040,7 @@ out_destroy: out_free: pr_info("%s: failed to register PMU devices!\n", of_node_full_name(node)); + kfree(pmu->irq_affinity); kfree(pmu); return ret; }