linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Potential uninitialized variables in power: supply: rt5033_battery:
@ 2019-10-04  4:21 Yizhuo Zhai
  2019-10-14  3:12 ` Sebastian Reichel
  0 siblings, 1 reply; 3+ messages in thread
From: Yizhuo Zhai @ 2019-10-04  4:21 UTC (permalink / raw)
  To: Sebastian Reichel, linux-pm, linux-kernel, Zhiyun Qian, Chengyu Song

Hi:

drivers/power/supply/rt5033_battery.c:

In function rt5033_battery_get_present(), variable "val" could be
uninitialized if regmap_read() returns -EINVAL. However, "val" is
used to decide the return value, which is potentially unsafe.

Also, we cannot simply return -EINVAL in rt5033_battery_get_present()
because it's not an acceptable return value.

Thanks for your time to check this case.

-- 
Kind Regards,

Yizhuo Zhai

Computer Science, Graduate Student
University of California, Riverside

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

* Re: Potential uninitialized variables in power: supply: rt5033_battery:
  2019-10-04  4:21 Potential uninitialized variables in power: supply: rt5033_battery: Yizhuo Zhai
@ 2019-10-14  3:12 ` Sebastian Reichel
  2019-10-14  3:55   ` Yizhuo Zhai
  0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Reichel @ 2019-10-14  3:12 UTC (permalink / raw)
  To: Yizhuo Zhai, Beomho Seo; +Cc: linux-pm, linux-kernel, Zhiyun Qian, Chengyu Song

[-- Attachment #1: Type: text/plain, Size: 619 bytes --]

Hi,

On Thu, Oct 03, 2019 at 09:21:44PM -0700, Yizhuo Zhai wrote:
> drivers/power/supply/rt5033_battery.c:
> 
> In function rt5033_battery_get_present(), variable "val" could be
> uninitialized if regmap_read() returns -EINVAL. However, "val" is
> used to decide the return value, which is potentially unsafe.
> 
> Also, we cannot simply return -EINVAL in rt5033_battery_get_present()
> because it's not an acceptable return value.
> 
> Thanks for your time to check this case.

Should be fine to just return false when regmap_read() fails.
Will you prepare a patch for that?

Thanks,

-- Sebastian

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: Potential uninitialized variables in power: supply: rt5033_battery:
  2019-10-14  3:12 ` Sebastian Reichel
@ 2019-10-14  3:55   ` Yizhuo Zhai
  0 siblings, 0 replies; 3+ messages in thread
From: Yizhuo Zhai @ 2019-10-14  3:55 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Beomho Seo, linux-pm, linux-kernel, Zhiyun Qian, Chengyu Song

Hi Sebastian:

Thanks for your explanation and I will send the patch accordingly.

On Sun, Oct 13, 2019 at 8:12 PM Sebastian Reichel <sre@kernel.org> wrote:
>
> Hi,
>
> On Thu, Oct 03, 2019 at 09:21:44PM -0700, Yizhuo Zhai wrote:
> > drivers/power/supply/rt5033_battery.c:
> >
> > In function rt5033_battery_get_present(), variable "val" could be
> > uninitialized if regmap_read() returns -EINVAL. However, "val" is
> > used to decide the return value, which is potentially unsafe.
> >
> > Also, we cannot simply return -EINVAL in rt5033_battery_get_present()
> > because it's not an acceptable return value.
> >
> > Thanks for your time to check this case.
>
> Should be fine to just return false when regmap_read() fails.
> Will you prepare a patch for that?
>
> Thanks,
>
> -- Sebastian



-- 
Kind Regards,

Yizhuo Zhai

Computer Science, Graduate Student
University of California, Riverside

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

end of thread, other threads:[~2019-10-14  3:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-04  4:21 Potential uninitialized variables in power: supply: rt5033_battery: Yizhuo Zhai
2019-10-14  3:12 ` Sebastian Reichel
2019-10-14  3:55   ` Yizhuo Zhai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).