Skip to content

Commit

Permalink
s3c-adc-battery: Fix possible NULL pointer dereference
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Syam Sidhardhan authored and Anton Vorontsov committed Mar 19, 2013
1 parent 9239ebc commit c6cc9fc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/power/s3c_adc_battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit c6cc9fc

Please sign in to comment.