linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] arch: nds32: Add IRQ check for platform_get_irq()
@ 2021-06-23  5:17 Jiajun Cao
  0 siblings, 0 replies; only message in thread
From: Jiajun Cao @ 2021-06-23  5:17 UTC (permalink / raw)
  Cc: yuanxzhang, Jiajun Cao, Xin Tan, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Nick Hu, Greentime Hu, Vincent Chen,
	linux-perf-users, linux-kernel

The function cpu_pmu_request_irq() neglects to check the return
value of platform_get_irq().

The error code (a negative number) of platform_get_irq(), i.e.,
irq, will be passed to request_irq(), which will cause the function
cpu_pmu_request_irq() to fail with -EINVAL, overriding the original
error code irq.

Fix it by adding a IRQ check before calling request_irq().

Signed-off-by: Jiajun Cao <jjcao20@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
---
 arch/nds32/kernel/perf_event_cpu.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/nds32/kernel/perf_event_cpu.c b/arch/nds32/kernel/perf_event_cpu.c
index 0ce6f9f307e6..6a6cbebaf5aa 100644
--- a/arch/nds32/kernel/perf_event_cpu.c
+++ b/arch/nds32/kernel/perf_event_cpu.c
@@ -1083,6 +1083,9 @@ static int cpu_pmu_request_irq(struct nds32_pmu *cpu_pmu, irq_handler_t handler)
 	}
 
 	irq = platform_get_irq(pmu_device, 0);
+	if (irq < 0)
+		return irq;
+
 	err = request_irq(irq, handler, IRQF_NOBALANCING, "nds32-pfm",
 			  cpu_pmu);
 	if (err) {
-- 
2.17.1

Please check whether it's meaningful to propagate the error code of platform_get_irq() or stop calling request_irq() early when irq is invalid. Thanks!


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-06-23  5:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-23  5:17 [PATCH] arch: nds32: Add IRQ check for platform_get_irq() Jiajun Cao

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).