[PATCH 5.15 122/779] irqchip/mips-gic: Check the return value of ioremap() in gic_of_init()

From: Greg Kroah-Hartman
Date: Mon Aug 15 2022 - 14:31:46 EST


From: William Dean <williamsukatube@xxxxxxx>

[ Upstream commit 71349cc85e5930dce78ed87084dee098eba24b59 ]

The function ioremap() in gic_of_init() can fail, so
its return value should be checked.

Reported-by: Hacash Robot <hacashRobot@xxxxxxxxxxx>
Signed-off-by: William Dean <williamsukatube@xxxxxxx>
Signed-off-by: Marc Zyngier <maz@xxxxxxxxxx>
Link: https://lore.kernel.org/r/20220723100128.2964304-1-williamsukatube@xxxxxxx
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---
drivers/irqchip/irq-mips-gic.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/irqchip/irq-mips-gic.c b/drivers/irqchip/irq-mips-gic.c
index f03f47ffea1e..d815285f1efe 100644
--- a/drivers/irqchip/irq-mips-gic.c
+++ b/drivers/irqchip/irq-mips-gic.c
@@ -767,6 +767,10 @@ static int __init gic_of_init(struct device_node *node,
}

mips_gic_base = ioremap(gic_base, gic_len);
+ if (!mips_gic_base) {
+ pr_err("Failed to ioremap gic_base\n");
+ return -ENOMEM;
+ }

gicconfig = read_gic_config();
gic_shared_intrs = gicconfig & GIC_CONFIG_NUMINTERRUPTS;
--
2.35.1