Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Syam Sidhardhan and committed by
Anton Vorontsov
c6cc9fc9 9239ebcf

+5 -2
+5 -2
drivers/power/s3c_adc_battery.c
··· 145 145 146 146 int new_level; 147 147 int full_volt; 148 - const struct s3c_adc_bat_thresh *lut = bat->pdata->lut_noac; 149 - unsigned int lut_size = bat->pdata->lut_noac_cnt; 148 + const struct s3c_adc_bat_thresh *lut; 149 + unsigned int lut_size; 150 150 151 151 if (!bat) { 152 152 dev_err(psy->dev, "no battery infos ?!\n"); 153 153 return -EINVAL; 154 154 } 155 + 156 + lut = bat->pdata->lut_noac; 157 + lut_size = bat->pdata->lut_noac_cnt; 155 158 156 159 if (bat->volt_value < 0 || bat->cur_value < 0 || 157 160 jiffies_to_msecs(jiffies - bat->timestamp) >