summaryrefslogtreecommitdiff
path: root/drivers/clocksource/arm_arch_timer.c
diff options
context:
space:
mode:
authorAnkit Mishra <ankimi@codeaurora.org>2019-07-05 12:25:29 +0530
committerAnkit Mishra <ankimi@codeaurora.org>2019-07-09 14:05:25 +0530
commitbacd235ea66e67d2727a5929b1c68ac2f4d84b07 (patch)
tree8a9df0e48f1295d8ec9ea3a64ccf8195f07b1a65 /drivers/clocksource/arm_arch_timer.c
parent3ae0451881ca4e3b145a37046fd76a359030bbba (diff)
clocksource: arm_arch_timer: Fix a NULL Pointer dereference
In case best_frame is not populated with virtual/physical capable frame, NULL pointer is passed as an argument to of_iomap .To avoid NULL pointer dereference add a check before. Change-Id: Ia7bad6630662ee3a4ad7c9226f9d3858b2e7a36c Signed-off-by: Ankit Mishra <ankimi@codeaurora.org>
Diffstat (limited to 'drivers/clocksource/arm_arch_timer.c')
-rw-r--r--drivers/clocksource/arm_arch_timer.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
index 6760f84faf06..bd55b201371e 100644
--- a/drivers/clocksource/arm_arch_timer.c
+++ b/drivers/clocksource/arm_arch_timer.c
@@ -752,7 +752,7 @@ CLOCKSOURCE_OF_DECLARE(armv8_arch_timer, "arm,armv8-timer", arch_timer_of_init);
static void __init arch_timer_mem_init(struct device_node *np)
{
struct device_node *frame, *best_frame = NULL;
- void __iomem *cntctlbase, *base;
+ void __iomem *cntctlbase, *base = NULL;
unsigned int irq;
u32 cnttidr;
@@ -790,7 +790,8 @@ static void __init arch_timer_mem_init(struct device_node *np)
best_frame = of_node_get(frame);
}
- base = arch_counter_base = of_iomap(best_frame, 0);
+ if (best_frame)
+ base = arch_counter_base = of_iomap(best_frame, 0);
if (!base) {
pr_err("arch_timer: Can't map frame's registers\n");
of_node_put(best_frame);