mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [BUG] power: supply: 88pm860x_battery: possible uninitialized-variable access in measure_vbatt()
@ 2021-07-28 10:24 Li Tuo
  2021-08-05 17:49 ` Sebastian Reichel
  0 siblings, 1 reply; 3+ messages in thread
From: Li Tuo @ 2021-07-28 10:24 UTC (permalink / raw)
  To: sre; +Cc: linux-pm, linux-kernel, baijiaju1990

Hello,

Our static analysis tool finds a possible uninitialized-variable access 
in the 88pm860x_battery driver in Linux 5.14.0-rc3:

In calc_soc():
369:    int ocv;
376:    switch (state) {
380:    case OCV_MODE_SLEEP:
381:        ret = measure_vbatt(info, OCV_MODE_SLEEP, &ocv);

In measure_vbatt(struct pm860x_battery_info *info, int state, int *data)
176:    switch (state) {
184:    case OCV_MODE_SLEEP:
201:        *data = ((*data & 0xff) * 27 * 25) >> 9;

If the variable state is OCV_MODE_SLEEP, the function measure_vbatt() is 
called with the argument &ocv,
and the corresponding parameter is data. Thus *data is uninitialized but 
it is used at line 201.

I am not quite sure whether this possible uninitialized-variable access 
is real and how to fix it if it is real.
Any feedback would be appreciated, thanks!

Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>

Best wishes,
Tuo Li

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-08-06  3:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-28 10:24 [BUG] power: supply: 88pm860x_battery: possible uninitialized-variable access in measure_vbatt() Li Tuo
2021-08-05 17:49 ` Sebastian Reichel
2021-08-06  3:29   ` Tuo Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®