Skip to contentSkip to conversation

opp: avoid uninitialized-variable use

PATCH In review Arnd Bergmann 2 participants 4 messages May 29, 2020 – Jun 1, 2020 Operating performance points (OPP)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 opp: avoid uninitialized-variable use

An uninitialized pointer is passed into another function but ignored there:

drivers/opp/core.c:875:32: error: variable 'opp' is uninitialized when used here [-Werror,-Wuninitialized]

                ret = _set_opp_bw(opp_table, opp, dev, true);
                                             ^~~
drivers/opp/core.c:849:34: note: initialize the variable 'opp' to silence this warning
        struct dev_pm_opp *old_opp, *opp;
                                        ^

gcc no longer warns about this, but it seems it really should, so change the code to just pass a NULL pointer here.

See-also: 78a5255ffb6a ("Stop the ad-hoc games with -Wno-maybe-initialized")

Fixes c57afacc9270 ("opp: Remove bandwidth votes when target_freq is zero")
---
 drivers/opp/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/opp/core.c +1 -1
index df12c3804533..7302f2631f8d 100644
@@ -872,7 +872,7 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
 			goto put_opp_table;
 		}
 
-		ret = _set_opp_bw(opp_table, opp, dev, true);
+		ret = _set_opp_bw(opp_table, NULL, dev, true);
 		if (ret)
 			return ret;
 
Signature · 1 line
2.26.2
#1 lore raw
Quoted 25 lines · Arnd Bergmann

An uninitialized pointer is passed into another function but ignored there:

drivers/opp/core.c:875:32: error: variable 'opp' is uninitialized when used here [-Werror,-Wuninitialized]

                ret = _set_opp_bw(opp_table, opp, dev, true);
                                             ^~~
drivers/opp/core.c:849:34: note: initialize the variable 'opp' to silence this warning
        struct dev_pm_opp *old_opp, *opp;
                                        ^

gcc no longer warns about this, but it seems it really should, so change the code to just pass a NULL pointer here.

See-also: 78a5255ffb6a ("Stop the ad-hoc games with -Wno-maybe-initialized")

Fixes c57afacc9270 ("opp: Remove bandwidth votes when target_freq is zero")
---
 drivers/opp/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/opp/core.c +0 -0
index df12c3804533..7302f2631f8d 100644

drivers/opp/core.c int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) · line 878

Quoted 8 lines
drivers/opp/core.c +1 -1
@@ -872,7 +872,7 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
 			goto put_opp_table;
 		}
 
-		ret = _set_opp_bw(opp_table, opp, dev, true);
+		ret = _set_opp_bw(opp_table, NULL, dev, true);
 		if (ret)
 			return ret;
 

Not sure why people are still seeing this, I pushed a fix for this 2 days back.

Signature · 1 line
viresh
#2 lore raw
Quoted 8 lines · Viresh Kumar
Quoted 7 lines · Arnd Bergmann

An uninitialized pointer is passed into another function but

drivers/opp/core.c +0 -0
@@ -872,7 +872,7 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
                      goto put_opp_table;
              }
 
Quoted 8 lines

drivers/opp/core.c int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) · line 878

Quoted 5 lines
drivers/opp/core.c +1 -1
-             ret = _set_opp_bw(opp_table, opp, dev, true);
+             ret = _set_opp_bw(opp_table, NULL, dev, true);
              if (ret)
                      return ret;
 

Not sure why people are still seeing this, I pushed a fix for this 2 days back.

I was on next-20200528, which was the first version that was broken for me, and I sent all my fixes after I had tested them. Since a lot of things got broken
at once that day, it took me until the end of 20200529 to get it all tested properly and then send them out.

Arnd

#3 lore raw
Quoted 18 lines · Arnd Bergmann
Quoted 8 lines · Viresh Kumar
Quoted 7 lines · Arnd Bergmann

An uninitialized pointer is passed into another function but

drivers/opp/core.c +0 -0
@@ -872,7 +872,7 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
                      goto put_opp_table;
              }
 
Quoted 8 lines

drivers/opp/core.c int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) · line 878

Quoted 5 lines
drivers/opp/core.c +1 -1
-             ret = _set_opp_bw(opp_table, opp, dev, true);
+             ret = _set_opp_bw(opp_table, NULL, dev, true);
              if (ret)
                      return ret;
 

Not sure why people are still seeing this, I pushed a fix for this 2 days back.

Quoted 5 lines

I was on next-20200528, which was the first version that was broken for me, and I sent all my fixes after I had tested them. Since a lot of things got broken
at once that day, it took me until the end of 20200529 to get it all tested properly and then send them out.

Okay, I asked as around 3-4 people have already sent out this patch to me :)

Signature · 1 line
viresh