summaryrefslogtreecommitdiffstats
path: root/drivers/power
diff options
context:
space:
mode:
authorSyam Sidhardhan <syamsidhardh@gmail.com>2013-02-25 04:33:25 +0530
committerAnton Vorontsov <anton@enomsg.org>2013-03-18 19:43:03 -0700
commitc6cc9fc9d42ec82da2c770f0bef1488dc467f29c (patch)
tree792940a7c9afc196d69453b2b96b8c65f7dd3fe9 /drivers/power
parent9239ebcffb9301eab75c638dcb702688884cc5d6 (diff)
downloadlinux-c6cc9fc9d42ec82da2c770f0bef1488dc467f29c.tar.bz2
s3c-adc-battery: Fix possible NULL pointer dereference
Check for (bat == NULL) has to be done before accessing bat Signed-off-by: Syam Sidhardhan <s.syam@samsung.com> Signed-off-by: Anton Vorontsov <anton@enomsg.org>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/s3c_adc_battery.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/power/s3c_adc_battery.c b/drivers/power/s3c_adc_battery.c
index d2ca989dcbdc..5948ce058bdd 100644
--- a/drivers/power/s3c_adc_battery.c
+++ b/drivers/power/s3c_adc_battery.c
@@ -145,14 +145,17 @@ static int s3c_adc_bat_get_property(struct power_supply *psy,
int new_level;
int full_volt;
- const struct s3c_adc_bat_thresh *lut = bat->pdata->lut_noac;
- unsigned int lut_size = bat->pdata->lut_noac_cnt;
+ const struct s3c_adc_bat_thresh *lut;
+ unsigned int lut_size;
if (!bat) {
dev_err(psy->dev, "no battery infos ?!\n");
return -EINVAL;
}
+ lut = bat->pdata->lut_noac;
+ lut_size = bat->pdata->lut_noac_cnt;
+
if (bat->volt_value < 0 || bat->cur_value < 0 ||
jiffies_to_msecs(jiffies - bat->timestamp) >
BAT_POLL_INTERVAL) {