diff options
author | Syam Sidhardhan <syamsidhardh@gmail.com> | 2013-02-24 18:03:25 -0500 |
---|---|---|
committer | Anton Vorontsov <anton@enomsg.org> | 2013-03-18 22:43:03 -0400 |
commit | c6cc9fc9d42ec82da2c770f0bef1488dc467f29c (patch) | |
tree | 792940a7c9afc196d69453b2b96b8c65f7dd3fe9 /drivers/power | |
parent | 9239ebcffb9301eab75c638dcb702688884cc5d6 (diff) |
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.c | 7 |
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, | |||
145 | 145 | ||
146 | int new_level; | 146 | int new_level; |
147 | int full_volt; | 147 | int full_volt; |
148 | const struct s3c_adc_bat_thresh *lut = bat->pdata->lut_noac; | 148 | const struct s3c_adc_bat_thresh *lut; |
149 | unsigned int lut_size = bat->pdata->lut_noac_cnt; | 149 | unsigned int lut_size; |
150 | 150 | ||
151 | if (!bat) { | 151 | if (!bat) { |
152 | dev_err(psy->dev, "no battery infos ?!\n"); | 152 | dev_err(psy->dev, "no battery infos ?!\n"); |
153 | return -EINVAL; | 153 | return -EINVAL; |
154 | } | 154 | } |
155 | 155 | ||
156 | lut = bat->pdata->lut_noac; | ||
157 | lut_size = bat->pdata->lut_noac_cnt; | ||
158 | |||
156 | if (bat->volt_value < 0 || bat->cur_value < 0 || | 159 | if (bat->volt_value < 0 || bat->cur_value < 0 || |
157 | jiffies_to_msecs(jiffies - bat->timestamp) > | 160 | jiffies_to_msecs(jiffies - bat->timestamp) > |
158 | BAT_POLL_INTERVAL) { | 161 | BAT_POLL_INTERVAL) { |