From: Andrew Morton <akpm@linux-foundation.org>
To: Axel Lin <axel.lin@gmail.com>
Cc: linux-kernel@vger.kernel.org,
Samu Onkalo <samu.p.onkalo@nokia.com>,
Richard Purdie <rpurdie@rpsys.net>
Subject: Re: [PATCH] leds: leds-lp5521: Avoid writing uninitialized value to LP5521_REG_OP_MODE register
Date: Wed, 5 Oct 2011 14:47:15 -0700 [thread overview]
Message-ID: <20111005144715.5e275a53.akpm@linux-foundation.org> (raw)
In-Reply-To: <1317806378.2834.6.camel@phoenix>
On Wed, 05 Oct 2011 17:19:38 +0800
Axel Lin <axel.lin@gmail.com> wrote:
> If lp5521_read fails, engine_state variable is not initialized.
> If lp5521_read fails, we should return error.
> This patch fixes below warning.
>
> CC drivers/leds/leds-lp5521.o
> drivers/leds/leds-lp5521.c: In function 'lp5521_set_engine_mode':
> drivers/leds/leds-lp5521.c:168: warning: 'engine_state' may be used uninitialized in this function
>
> Signed-off-by: Axel Lin <axel.lin@gmail.com>
> ---
> drivers/leds/leds-lp5521.c | 2 ++
> 1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c
> index 9fc122c..89134d9 100644
> --- a/drivers/leds/leds-lp5521.c
> +++ b/drivers/leds/leds-lp5521.c
> @@ -175,6 +175,8 @@ static int lp5521_set_engine_mode(struct lp5521_engine *engine, u8 mode)
> mode = LP5521_CMD_DIRECT;
>
> ret = lp5521_read(client, LP5521_REG_OP_MODE, &engine_state);
> + if (ret < 0)
> + return ret;
>
> /* set mode only for this engine */
> engine_state &= ~(engine->engine_mask);
OK. And the later "ret |=" whcih was previously a bug is now just
unneeded.
--- a/drivers/leds/leds-lp5521.c~leds-leds-lp5521-avoid-writing-uninitialized-value-to-lp5521_reg_op_mode-register-fix
+++ a/drivers/leds/leds-lp5521.c
@@ -182,9 +182,7 @@ static int lp5521_set_engine_mode(struct
engine_state &= ~(engine->engine_mask);
mode &= engine->engine_mask;
engine_state |= mode;
- ret |= lp5521_write(client, LP5521_REG_OP_MODE, engine_state);
-
- return ret;
+ return lp5521_write(client, LP5521_REG_OP_MODE, engine_state);
}
static int lp5521_load_program(struct lp5521_engine *eng, const u8 *pattern)
_
prev parent reply other threads:[~2011-10-05 21:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-05 9:19 [PATCH] leds: leds-lp5521: Avoid writing uninitialized value to LP5521_REG_OP_MODE register Axel Lin
2011-10-05 21:47 ` Andrew Morton [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=20111005144715.5e275a53.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=axel.lin@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rpurdie@rpsys.net \
--cc=samu.p.onkalo@nokia.com \
/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