target: init: Change data type to prevent integer overflow
Change u32 type casting to u64 type casting for temporary variable
to prevent integer overflow that may result in certain scenarios.
CRs-Fixed: 2160546
Change-Id: I02deb6bebb424ec6da60a7416a992dff2508b06f
Signed-off-by: Umang Agrawal <uagrawal@codeaurora.org>
diff --git a/target/init.c b/target/init.c
index fed33cc..c67aadc 100644
--- a/target/init.c
+++ b/target/init.c
@@ -1,7 +1,7 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
- * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
@@ -481,7 +481,7 @@
buff[1] = REG_READ(BATT_INFO_VBATT_MSB);
temp = buff[1] << 8 | buff[0];
/* {MSB,LSB} to decode the voltage level, refer register description. */
- vbat = (((uint32_t)temp)*BATT_VOLTAGE_NUMR/BATT_VOLTAGE_DENR);
+ vbat = (((uint64_t)temp)*BATT_VOLTAGE_NUMR/BATT_VOLTAGE_DENR);
break;
default:
dprintf(CRITICAL, "ERROR: Couldn't get the pmic type\n");