lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Wed, 23 Jun 2021 13:17:10 +0800
From:   Jiajun Cao <jjcao20@...an.edu.cn>
To:     unlisted-recipients:; (no To-header on input)
Cc:     yuanxzhang@...an.edu.cn, Jiajun Cao <jjcao20@...an.edu.cn>,
        Xin Tan <tanxin.ctf@...il.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Jiri Olsa <jolsa@...hat.com>,
        Namhyung Kim <namhyung@...nel.org>,
        Nick Hu <nickhu@...estech.com>,
        Greentime Hu <green.hu@...il.com>,
        Vincent Chen <deanbo422@...il.com>,
        linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] arch: nds32: Add IRQ check for platform_get_irq()

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@...an.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@...il.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!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ