From patchwork Sat Aug 27 16:19:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 9302461 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 E029E608A7 for ; Sat, 27 Aug 2016 16:23:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE3DB289D2 for ; Sat, 27 Aug 2016 16:23:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B4E1C289D0; Sat, 27 Aug 2016 16:23:11 +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 EE3F628119 for ; Sat, 27 Aug 2016 16:23:09 +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 1bdgM7-0002jE-Vv; Sat, 27 Aug 2016 16:21:15 +0000 Received: from mout.kundenserver.de ([212.227.17.10]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bdgLr-0002gM-Mm for linux-arm-kernel@lists.infradead.org; Sat, 27 Aug 2016 16:21:01 +0000 Received: from localhost.localdomain ([95.91.36.119]) by mrelayeu.kundenserver.de (mreue103) with ESMTPSA (Nemesis) id 0Lp9KG-1b9pAn3sii-00ewhs; Sat, 27 Aug 2016 18:20:22 +0200 From: Stefan Wahren To: Mark Rutland , Will Deacon Subject: [PATCH 2/2] drivers/perf: arm_pmu: Fix NULL pointer dereference during probe Date: Sat, 27 Aug 2016 16:19:50 +0000 Message-Id: <1472314790-4268-2-git-send-email-stefan.wahren@i2se.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1472314790-4268-1-git-send-email-stefan.wahren@i2se.com> References: <1472314790-4268-1-git-send-email-stefan.wahren@i2se.com> X-Provags-ID: V03:K0:hkQa4Duoj+cKt7oh98SD1vsIwGGExs/wcw09oCAOxGDN+XGvvDq xiVZOixxmq4p38117NoCfMXefTx/WpBE6PlrgUD5G8TOul82zfMWmp8N4xUiPl2wJ5EB7u4 JHA13BTD1WIDO4CcGH+va2dV1XFd5fM4bfP8EnhemeeVqG9MXz6CcY8EzSCGMcTPsWngTlL ri0mpfpglNzMYdU+AyCUg== X-UI-Out-Filterresults: notjunk:1; V01:K0:8Y8iIhGRyQw=:/V8L8sprHarx7nKZ+8+hgZ ZR+qYHYe0zieWn9A7luZyyPM7NIeP3Nqzs82t7WNhHzrUePd3kQxg8nSEZOlLM2G+HfulVekq 5qrwmnMUrgzAvqqckEI0vvMZIu9nMRnvJ19spH1skgQILBfi1mtnSIejZ71WIt535iJ5TmE6A oTNueUSU68vZaUow3KV7eIPhKOvkHIBFSK+DY3OHNE0ob2g3RWLW5gQMgGdopgJrAp+R5Cife kiXGicKPAT0tDQInv6hsbwMucxYy/jgRB+sC+qA08lg2TyvImfg1psoIIHIXH6vFaH24RIDvV neBSS36af+SEZdb1ZWUKujr74+LkNS/b840bDlY2uPxVKhmx9PQTSeok9sfQgrmgGkt3pgxDe gFEeanyQ6RINCmflTc6TNTGUJUcfY1jVrHOz/BjmXz3BQVn4GmJ7Z7RzqKnT+/YCUM5a0MVPy cyVEYee8bdx8c2s/ooqyLBhN8Ve+iXxS2pXnJmSuYET2j8Wbe08A15y8sz71ycmmuOL5i9Rn8 8ifQ6etRm/DowY6y2f6s9oEJAYMInEZHLklq0MLxwW5b5vmDXak7OxeIGe88dLNGl8R5Y1loC gMQN7/D4Cwu/dgIslDdPybetH/6G0Vv0iabP5j56so/+3JK/c9AiVMUzgODClDhzqA/BP5EyF psi7q5sFbLztXCHmH45gUHHzEswZ5LkJJYHbznCA5K/5C9SqIKuB2cOU+qQ2VWHbstgQ= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160827_092100_139974_7B772B91 X-CRM114-Status: GOOD ( 10.42 ) 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: Stefan Wahren , Eric Anholt , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org 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 Patch 7f1d642fbb5c ("drivers/perf: arm-pmu: Fix handling of SPI lacking interrupt-affinity property") unintended also fixes perf_event support for bcm2835 which doesn't have PMU interrupts. Unfortunately this change introduce a NULL pointer dereference on bcm2835, because irq_is_percpu always expected to be called with a valid IRQ. So fix this regression by validating the IRQ before. Signed-off-by: Stefan Wahren Fixes: 7f1d642fbb5c ("drivers/perf: arm-pmu: Fix handling of SPI lacking \"interrupt-affinity\" property") Tested-by: Kevin Hilman --- drivers/perf/arm_pmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Note: checkpatch.pl complains about the fixes tag, but i don't know how to escape it correctly. diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c index 1b48bf0..f5e1008 100644 --- a/drivers/perf/arm_pmu.c +++ b/drivers/perf/arm_pmu.c @@ -970,7 +970,7 @@ static int of_pmu_irq_cfg(struct arm_pmu *pmu) if (cpumask_weight(&pmu->supported_cpus) == 0) { int irq = platform_get_irq(pdev, 0); - if (irq_is_percpu(irq)) { + if (irq >= 0 && irq_is_percpu(irq)) { /* If using PPIs, check the affinity of the partition */ int ret;