summaryrefslogtreecommitdiff
path: root/drivers/power
diff options
context:
space:
mode:
authorAbhijeet Dharmapurikar <adharmap@codeaurora.org>2016-09-13 10:36:48 -0700
committerAbhijeet Dharmapurikar <adharmap@codeaurora.org>2016-10-20 17:26:45 -0700
commitbc2dcbfae6262d98c7d8fe9a0401a783816f8deb (patch)
tree2ec83c97fbf5cbfebd612dc80384882c389c9acf /drivers/power
parent9b82a4c5896632b62140d1ddda55638fea254007 (diff)
smb1351-charger: Fix possible Null pointer dereference
The adc notification callback assumes that it will end up selecting the correct state. However, if the parameters are outside the expected values, the code could end up dereferencing a null pointer. Fix this by returning before that pointer is dereferenced. Change-Id: I42642b475a1032c3a7395336381f3bd6c1396dde Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/qcom-charger/smb1351-charger.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/power/qcom-charger/smb1351-charger.c b/drivers/power/qcom-charger/smb1351-charger.c
index 0f18844b9afa..79fbe33acf5d 100644
--- a/drivers/power/qcom-charger/smb1351-charger.c
+++ b/drivers/power/qcom-charger/smb1351-charger.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015 The Linux Foundation. All rights reserved.
+/* Copyright (c) 2016 The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -1872,6 +1872,12 @@ static void smb1351_chg_adc_notification(enum qpnp_tm_state state, void *ctx)
}
}
+ if (!cur) {
+ pr_debug("Couldn't choose batt state, adc state=%d and temp=%d\n",
+ state, temp);
+ return;
+ }
+
if (cur->batt_present)
chip->battery_missing = false;
else