linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] drivers/perf: arm_pmu: Fix leak in error path
@ 2016-08-27 16:19 Stefan Wahren
  2016-08-27 16:19 ` [PATCH 2/2] drivers/perf: arm_pmu: Fix NULL pointer dereference during probe Stefan Wahren
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Wahren @ 2016-08-27 16:19 UTC (permalink / raw)
  To: Mark Rutland, Will Deacon
  Cc: Eric Anholt, linux-arm-kernel, linux-kernel, Stefan Wahren

In case of a IRQ type mismatch in of_pmu_irq_cfg() the
device node for interrupt affinity isn't freed. So fix this
issue by calling of_node_put().

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Fixes: fa8ad7889d83 ("arm: perf: factor arm_pmu core out to drivers")
---
 drivers/perf/arm_pmu.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c
index c494613..1b48bf0 100644
--- a/drivers/perf/arm_pmu.c
+++ b/drivers/perf/arm_pmu.c
@@ -925,6 +925,7 @@ static int of_pmu_irq_cfg(struct arm_pmu *pmu)
 			if (i > 0 && spi != using_spi) {
 				pr_err("PPI/SPI IRQ type mismatch for %s!\n",
 					dn->name);
+				of_node_put(dn);
 				kfree(irqs);
 				return -EINVAL;
 			}
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] drivers/perf: arm_pmu: Fix NULL pointer dereference during probe
  2016-08-27 16:19 [PATCH 1/2] drivers/perf: arm_pmu: Fix leak in error path Stefan Wahren
@ 2016-08-27 16:19 ` Stefan Wahren
  2016-08-30 11:27   ` Will Deacon
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Wahren @ 2016-08-27 16:19 UTC (permalink / raw)
  To: Mark Rutland, Will Deacon
  Cc: Eric Anholt, linux-arm-kernel, linux-kernel, Stefan Wahren

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 <stefan.wahren@i2se.com>
Fixes: 7f1d642fbb5c ("drivers/perf: arm-pmu: Fix handling of SPI lacking \"interrupt-affinity\" property")
---
 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;
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] drivers/perf: arm_pmu: Fix NULL pointer dereference during probe
  2016-08-27 16:19 ` [PATCH 2/2] drivers/perf: arm_pmu: Fix NULL pointer dereference during probe Stefan Wahren
@ 2016-08-30 11:27   ` Will Deacon
  2016-09-01  2:17     ` Kevin Hilman
  0 siblings, 1 reply; 4+ messages in thread
From: Will Deacon @ 2016-08-30 11:27 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Mark Rutland, Eric Anholt, linux-arm-kernel, linux-kernel, marc.zyngier

On Sat, Aug 27, 2016 at 04:19:50PM +0000, Stefan Wahren wrote:
> 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 <stefan.wahren@i2se.com>
> Fixes: 7f1d642fbb5c ("drivers/perf: arm-pmu: Fix handling of SPI lacking \"interrupt-affinity\" property")
> ---
>  drivers/perf/arm_pmu.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Thanks, these two look good to me. I'll queue them up as fixes and hopefully
they'll land in -rc5.

Will

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] drivers/perf: arm_pmu: Fix NULL pointer dereference during probe
  2016-08-30 11:27   ` Will Deacon
@ 2016-09-01  2:17     ` Kevin Hilman
  0 siblings, 0 replies; 4+ messages in thread
From: Kevin Hilman @ 2016-09-01  2:17 UTC (permalink / raw)
  To: Will Deacon
  Cc: Stefan Wahren, Mark Rutland, Eric Anholt, linux-kernel,
	linux-arm-kernel, marc.zyngier

Will Deacon <will.deacon@arm.com> writes:

> On Sat, Aug 27, 2016 at 04:19:50PM +0000, Stefan Wahren wrote:
>> 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 <stefan.wahren@i2se.com>
>> Fixes: 7f1d642fbb5c ("drivers/perf: arm-pmu: Fix handling of SPI lacking \"interrupt-affinity\" property")
>> ---
>>  drivers/perf/arm_pmu.c |    2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> Thanks, these two look good to me. I'll queue them up as fixes and hopefully
> they'll land in -rc5.

FWIW, I tested this on bcm2835-rpi and verified it fixes the boot
problem in mainline.

Tested-by: Kevin Hilman <khilman@baylibre.com>

Kevin

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-09-01  2:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-27 16:19 [PATCH 1/2] drivers/perf: arm_pmu: Fix leak in error path Stefan Wahren
2016-08-27 16:19 ` [PATCH 2/2] drivers/perf: arm_pmu: Fix NULL pointer dereference during probe Stefan Wahren
2016-08-30 11:27   ` Will Deacon
2016-09-01  2:17     ` Kevin Hilman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).