* [PATCH] PM / clock_ops: initialize ret to avoid garbage being returned
@ 2015-01-08 15:31 Colin King
2015-01-18 21:00 ` Pavel Machek
0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2015-01-08 15:31 UTC (permalink / raw)
To: Rafael J. Wysocki, Len Brown, Pavel Machek, linux-pm; +Cc: linux-kernel
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);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] PM / clock_ops: initialize ret to avoid garbage being returned
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
0 siblings, 0 replies; 2+ messages in thread
From: Pavel Machek @ 2015-01-18 21:00 UTC (permalink / raw)
To: Colin King; +Cc: Rafael J. Wysocki, Len Brown, linux-pm, linux-kernel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-01-18 21:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 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).