linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] opp: avoid uninitialized-variable use
@ 2020-05-29 20:17 Arnd Bergmann
  2020-05-30  9:20 ` Viresh Kumar
  0 siblings, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2020-05-29 20:17 UTC (permalink / raw)
  To: Viresh Kumar, Nishanth Menon, Stephen Boyd, Georgi Djakov
  Cc: Arnd Bergmann, Sibi Sankar, Viresh Kumar, Matthias Kaehlcke,
	Rajendra Nayak, linux-pm, linux-kernel

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")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/opp/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/opp/core.c b/drivers/opp/core.c
index df12c3804533..7302f2631f8d 100644
--- a/drivers/opp/core.c
+++ b/drivers/opp/core.c
@@ -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;
 
-- 
2.26.2


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

* Re: [PATCH] opp: avoid uninitialized-variable use
  2020-05-29 20:17 [PATCH] opp: avoid uninitialized-variable use Arnd Bergmann
@ 2020-05-30  9:20 ` Viresh Kumar
  2020-05-30 12:40   ` Arnd Bergmann
  0 siblings, 1 reply; 4+ messages in thread
From: Viresh Kumar @ 2020-05-30  9:20 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Viresh Kumar, Nishanth Menon, Stephen Boyd, Georgi Djakov,
	Sibi Sankar, Matthias Kaehlcke, Rajendra Nayak, linux-pm,
	linux-kernel

On 29-05-20, 22:17, Arnd Bergmann wrote:
> 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")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/opp/core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/opp/core.c b/drivers/opp/core.c
> index df12c3804533..7302f2631f8d 100644
> --- a/drivers/opp/core.c
> +++ b/drivers/opp/core.c
> @@ -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.

-- 
viresh

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

* Re: [PATCH] opp: avoid uninitialized-variable use
  2020-05-30  9:20 ` Viresh Kumar
@ 2020-05-30 12:40   ` Arnd Bergmann
  2020-06-01  3:32     ` Viresh Kumar
  0 siblings, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2020-05-30 12:40 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Viresh Kumar, Nishanth Menon, Stephen Boyd, Georgi Djakov,
	Sibi Sankar, Matthias Kaehlcke, Rajendra Nayak, Linux PM list,
	linux-kernel

On Sat, May 30, 2020 at 11:21 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
> On 29-05-20, 22:17, Arnd Bergmann wrote:
> > An uninitialized pointer is passed into another function but
> > --- a/drivers/opp/core.c
> > +++ b/drivers/opp/core.c
> > @@ -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.

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

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

* Re: [PATCH] opp: avoid uninitialized-variable use
  2020-05-30 12:40   ` Arnd Bergmann
@ 2020-06-01  3:32     ` Viresh Kumar
  0 siblings, 0 replies; 4+ messages in thread
From: Viresh Kumar @ 2020-06-01  3:32 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Viresh Kumar, Nishanth Menon, Stephen Boyd, Georgi Djakov,
	Sibi Sankar, Matthias Kaehlcke, Rajendra Nayak, Linux PM list,
	linux-kernel

On 30-05-20, 14:40, Arnd Bergmann wrote:
> On Sat, May 30, 2020 at 11:21 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
> > On 29-05-20, 22:17, Arnd Bergmann wrote:
> > > An uninitialized pointer is passed into another function but
> > > --- a/drivers/opp/core.c
> > > +++ b/drivers/opp/core.c
> > > @@ -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.
> 
> 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 :)

-- 
viresh

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

end of thread, other threads:[~2020-06-01  3:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-29 20:17 [PATCH] opp: avoid uninitialized-variable use Arnd Bergmann
2020-05-30  9:20 ` Viresh Kumar
2020-05-30 12:40   ` Arnd Bergmann
2020-06-01  3:32     ` Viresh Kumar

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).