linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: u.kleine-koenig@pengutronix.de (Uwe Kleine-König)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] clk: __clk_set_parent: set uninitialized variable
Date: Mon, 2 Jul 2012 08:47:37 +0200	[thread overview]
Message-ID: <20120702064737.GB22016@pengutronix.de> (raw)
In-Reply-To: <4FF13839.5000804@ti.com>

On Mon, Jul 02, 2012 at 11:27:13AM +0530, Rajendra Nayak wrote:
> On Monday 02 July 2012 02:48 AM, Marc Kleine-Budde wrote:
> >This patch fixes the following warning:
> >
> >     drivers/clk/clk.c: In function '__clk_set_parent':
> >     drivers/clk/clk.c:1083:5: warning: 'i' may be used uninitialized in this function [-Wuninitialized]
> >
> >which has been introduced with commit:
> 
> hmm, are you sure about that? The below commit neither introduces the
> variable 'i', nor seem to change the way the variable is used in the
> function.
It does. The following hunk:

-       for (i = 0; i < clk->num_parents; i++)
-               if (clk->parents[i] == parent)
-                       break;
+       if (clk->parents)
+               for (i = 0; i < clk->num_parents; i++)
+                       if (clk->parents[i] == parent)
+                               break;
+       else
+               clk->parents = kzalloc((sizeof(struct clk*) * clk->num_parents),
+                                                               GFP_KERNEL);

results in i being uninitialized if clk->parents is NULL. But I wonder
if for this case i should be set to clk->num_parents instead of 0?

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

  reply	other threads:[~2012-07-02  6:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-01 21:18 [PATCH] clk: __clk_set_parent: set uninitialized variable Marc Kleine-Budde
2012-07-02  5:57 ` Rajendra Nayak
2012-07-02  6:47   ` Uwe Kleine-König [this message]
2012-07-02  7:24     ` Rajendra Nayak

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=20120702064737.GB22016@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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).