* [PATCH] extcon: axp288: Variable "val" could be uninitialized if regmap_read() fails
@ 2019-09-02 22:41 Yizhuo
[not found] ` <CAHp75VcWA22y2Diinp9rnq1GGR_YFHvaunYCS3eAVcrAuccP8Q@mail.gmail.com>
0 siblings, 1 reply; 2+ messages in thread
From: Yizhuo @ 2019-09-02 22:41 UTC (permalink / raw)
Cc: csong, zhiyunq, Yizhuo, MyungJoo Ham, Chanwoo Choi, Chen-Yu Tsai,
Hans de Goede, linux-kernel
In function axp288_extcon_log_rsi(), variable "val" could be
uninitialized if regmap_read() fails. However, it's ued to
decide the control flow later in the if statement, which is
potentially unsafe.
Signed-off-by: Yizhuo <yzhai003@ucr.edu>
---
drivers/extcon/extcon-axp288.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/extcon/extcon-axp288.c b/drivers/extcon/extcon-axp288.c
index 7254852e6ec0..54116a926ab6 100644
--- a/drivers/extcon/extcon-axp288.c
+++ b/drivers/extcon/extcon-axp288.c
@@ -135,6 +135,11 @@ static void axp288_extcon_log_rsi(struct axp288_extcon_info *info)
int ret;
ret = regmap_read(info->regmap, AXP288_PS_BOOT_REASON_REG, &val);
+ if (ret) {
+ dev_err(info->dev, "failed to read AXP288_PS_BOOT_REASON_REG\n");
+ return;
+ }
+
for (i = 0, rsi = axp288_pwr_up_down_info; *rsi; rsi++, i++) {
if (val & BIT(i)) {
dev_dbg(info->dev, "%s\n", *rsi);
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] extcon: axp288: Variable "val" could be uninitialized if regmap_read() fails
[not found] ` <CAHp75VcWA22y2Diinp9rnq1GGR_YFHvaunYCS3eAVcrAuccP8Q@mail.gmail.com>
@ 2019-09-02 23:23 ` Yizhuo Zhai
0 siblings, 0 replies; 2+ messages in thread
From: Yizhuo Zhai @ 2019-09-02 23:23 UTC (permalink / raw)
To: Andy Shevchenko
Cc: csong, zhiyunq, MyungJoo Ham, Chanwoo Choi, Chen-Yu Tsai,
Hans de Goede, linux-kernel
Thanks Andy, sorry for the inconvenience, I will check the log more
carefully next time.
On Mon, Sep 2, 2019 at 3:48 PM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
>
>
>
> On Tuesday, September 3, 2019, Yizhuo <yzhai003@ucr.edu> wrote:
>>
>> In function axp288_extcon_log_rsi(), variable "val" could be
>> uninitialized if regmap_read() fails. However, it's ued to
>> decide the control flow later in the if statement, which is
>> potentially unsafe.
>
>
> https://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/extcon.git/commit/?h=extcon-next&id=d72e3dc7915fc6c54645772c13f4afc0e676c7e2
>
>>
>> Signed-off-by: Yizhuo <yzhai003@ucr.edu>
>> ---
>> drivers/extcon/extcon-axp288.c | 5 +++++
>> 1 file changed, 5 insertions(+)
>>
>> diff --git a/drivers/extcon/extcon-axp288.c b/drivers/extcon/extcon-axp288.c
>> index 7254852e6ec0..54116a926ab6 100644
>> --- a/drivers/extcon/extcon-axp288.c
>> +++ b/drivers/extcon/extcon-axp288.c
>> @@ -135,6 +135,11 @@ static void axp288_extcon_log_rsi(struct axp288_extcon_info *info)
>> int ret;
>>
>> ret = regmap_read(info->regmap, AXP288_PS_BOOT_REASON_REG, &val);
>> + if (ret) {
>> + dev_err(info->dev, "failed to read AXP288_PS_BOOT_REASON_REG\n");
>> + return;
>> + }
>> +
>> for (i = 0, rsi = axp288_pwr_up_down_info; *rsi; rsi++, i++) {
>> if (val & BIT(i)) {
>> dev_dbg(info->dev, "%s\n", *rsi);
>> --
>> 2.17.1
>>
>
>
> --
> With Best Regards,
> Andy Shevchenko
>
>
--
Kind Regards,
Yizhuo Zhai
Computer Science, Graduate Student
University of California, Riverside
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-09-02 23:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-02 22:41 [PATCH] extcon: axp288: Variable "val" could be uninitialized if regmap_read() fails Yizhuo
[not found] ` <CAHp75VcWA22y2Diinp9rnq1GGR_YFHvaunYCS3eAVcrAuccP8Q@mail.gmail.com>
2019-09-02 23:23 ` 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).