linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: Colin King <colin.king@canonical.com>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Len Brown <len.brown@intel.com>,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] PM / clock_ops: initialize ret to avoid garbage being returned
Date: Sun, 18 Jan 2015 22:00:36 +0100	[thread overview]
Message-ID: <20150118210036.GA31807@amd> (raw)
In-Reply-To: <1420731061-5029-1-git-send-email-colin.king@canonical.com>

On Thu 2015-01-08 15:31:01, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> cppcheck detected an unitialised ret:
>   [drivers/base/power/clock_ops.c:53]: (error) Uninitialized variable: ret
> 
> ret is only assigned if ce->status < PCE_STATUS_ERROR, if this is false
> then __pm_clk_enable returns whatever garbage ret picks up from the stack.
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

> ---
>  drivers/base/power/clock_ops.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/base/power/clock_ops.c b/drivers/base/power/clock_ops.c
> index d626576..5bd283d 100644
> --- a/drivers/base/power/clock_ops.c
> +++ b/drivers/base/power/clock_ops.c
> @@ -39,7 +39,7 @@ struct pm_clock_entry {
>   */
>  static inline int __pm_clk_enable(struct device *dev, struct pm_clock_entry *ce)
>  {
> -	int ret;
> +	int ret = 0;
>  
>  	if (ce->status < PCE_STATUS_ERROR) {
>  		ret = clk_enable(ce->clk);

Actually, is this right solution? If clock entry has an error, we
won't enable it, and should probably return some kind of error...?

									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

      reply	other threads:[~2015-01-18 21:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-08 15:31 [PATCH] PM / clock_ops: initialize ret to avoid garbage being returned Colin King
2015-01-18 21:00 ` Pavel Machek [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150118210036.GA31807@amd \
    --to=pavel@ucw.cz \
    --cc=colin.king@canonical.com \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).