lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Wed, 5 Oct 2011 14:47:15 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Axel Lin <axel.lin@...il.com>
Cc:	linux-kernel@...r.kernel.org,
	Samu Onkalo <samu.p.onkalo@...ia.com>,
	Richard Purdie <rpurdie@...ys.net>
Subject: Re: [PATCH] leds: leds-lp5521: Avoid writing uninitialized value to
 LP5521_REG_OP_MODE register

On Wed, 05 Oct 2011 17:19:38 +0800
Axel Lin <axel.lin@...il.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@...il.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)
_

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ