Re: [PATCH] image: Fix potentially uninitialized data variable

2023-03-31 Thread Tom Rini
On Mon, Feb 27, 2023 at 08:56:31PM +0100, Marek Vasut wrote:

> In case fitImage support is disabled, and image_locate_script() is
> passed a fitImage, then the 'data' variable is used uninitialized.
> Drop into the default: branch of the switch-case statement and do
> not return the uninitialized data, and do not modify the return
> pointer either, just print an error message.
> 
> Reported by clang build:
> "
> $ make HOSTCC=clang CC=clang KCFLAGS=-Werror sandbox64_defconfig && make 
> HOSTCC=clang CC=clang KCFLAGS=-Werror
> ...
> boot/image-board.c:1006:7: error: variable 'data' is used uninitialized 
> whenever switch case is taken [-Werror,-Wsometimes-uninitialized]
> case IMAGE_FORMAT_LEGACY:
>  ^~~
> include/image.h:608:29: note: expanded from macro 'IMAGE_FORMAT_LEGACY'
> ^~~~
> boot/image-board.c:1128:19: note: uninitialized use occurs here
> *datap = (char *)data;
>  ^~~~
> boot/image-board.c:1001:11: note: initialize the variable 'data' to silence 
> this warning
> u32 *data;
>  ^
>   = NULL
> "
> 
> Signed-off-by: Marek Vasut 
> Reviewed-by: Tom Rini 
> Reviewed-by: Simon Glass 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] image: Fix potentially uninitialized data variable

2023-03-01 Thread Marek Vasut

On 3/1/23 17:02, Tom Rini wrote:

On Mon, Feb 27, 2023 at 08:56:31PM +0100, Marek Vasut wrote:


In case fitImage support is disabled, and image_locate_script() is
passed a fitImage, then the 'data' variable is used uninitialized.
Drop into the default: branch of the switch-case statement and do
not return the uninitialized data, and do not modify the return
pointer either, just print an error message.

Reported by clang build:
"
$ make HOSTCC=clang CC=clang KCFLAGS=-Werror sandbox64_defconfig && make 
HOSTCC=clang CC=clang KCFLAGS=-Werror
...
boot/image-board.c:1006:7: error: variable 'data' is used uninitialized 
whenever switch case is taken [-Werror,-Wsometimes-uninitialized]
 case IMAGE_FORMAT_LEGACY:
  ^~~
include/image.h:608:29: note: expanded from macro 'IMAGE_FORMAT_LEGACY'
 ^~~~
boot/image-board.c:1128:19: note: uninitialized use occurs here
 *datap = (char *)data;
  ^~~~
boot/image-board.c:1001:11: note: initialize the variable 'data' to silence 
this warning
 u32 *data;
  ^
   = NULL
"

Signed-off-by: Marek Vasut 


Reviewed-by: Tom Rini 

And can you please do a follow-up that adds sandbox64 + clang, after the
sandbox + clang test in GitLab/Azure?


The CI is chewing on it here:

ahttps://source.denx.de/u-boot/custodians/u-boot-sh/-/commit/f80a434c2ea4fdae7adf0e4c4a0ecd9784d6808e


Re: [PATCH] image: Fix potentially uninitialized data variable

2023-03-01 Thread Simon Glass
On Mon, 27 Feb 2023 at 12:56, Marek Vasut
 wrote:
>
> In case fitImage support is disabled, and image_locate_script() is
> passed a fitImage, then the 'data' variable is used uninitialized.
> Drop into the default: branch of the switch-case statement and do
> not return the uninitialized data, and do not modify the return
> pointer either, just print an error message.
>
> Reported by clang build:
> "
> $ make HOSTCC=clang CC=clang KCFLAGS=-Werror sandbox64_defconfig && make 
> HOSTCC=clang CC=clang KCFLAGS=-Werror
> ...
> boot/image-board.c:1006:7: error: variable 'data' is used uninitialized 
> whenever switch case is taken [-Werror,-Wsometimes-uninitialized]
> case IMAGE_FORMAT_LEGACY:
>  ^~~
> include/image.h:608:29: note: expanded from macro 'IMAGE_FORMAT_LEGACY'
> ^~~~
> boot/image-board.c:1128:19: note: uninitialized use occurs here
> *datap = (char *)data;
>  ^~~~
> boot/image-board.c:1001:11: note: initialize the variable 'data' to silence 
> this warning
> u32 *data;
>  ^
>   = NULL
> "
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: Heinrich Schuchardt 
> Cc: Michal Simek 
> Cc: Oleksandr Suvorov 
> Cc: Simon Glass 
> Cc: Stefan Roese 
> Cc: Tom Rini 
> ---
>  boot/image-board.c | 15 +++
>  1 file changed, 11 insertions(+), 4 deletions(-)
>

Reviewed-by: Simon Glass 


Re: [PATCH] image: Fix potentially uninitialized data variable

2023-03-01 Thread Tom Rini
On Mon, Feb 27, 2023 at 08:56:31PM +0100, Marek Vasut wrote:

> In case fitImage support is disabled, and image_locate_script() is
> passed a fitImage, then the 'data' variable is used uninitialized.
> Drop into the default: branch of the switch-case statement and do
> not return the uninitialized data, and do not modify the return
> pointer either, just print an error message.
> 
> Reported by clang build:
> "
> $ make HOSTCC=clang CC=clang KCFLAGS=-Werror sandbox64_defconfig && make 
> HOSTCC=clang CC=clang KCFLAGS=-Werror
> ...
> boot/image-board.c:1006:7: error: variable 'data' is used uninitialized 
> whenever switch case is taken [-Werror,-Wsometimes-uninitialized]
> case IMAGE_FORMAT_LEGACY:
>  ^~~
> include/image.h:608:29: note: expanded from macro 'IMAGE_FORMAT_LEGACY'
> ^~~~
> boot/image-board.c:1128:19: note: uninitialized use occurs here
> *datap = (char *)data;
>  ^~~~
> boot/image-board.c:1001:11: note: initialize the variable 'data' to silence 
> this warning
> u32 *data;
>  ^
>   = NULL
> "
> 
> Signed-off-by: Marek Vasut 

Reviewed-by: Tom Rini 

And can you please do a follow-up that adds sandbox64 + clang, after the
sandbox + clang test in GitLab/Azure?

-- 
Tom


signature.asc
Description: PGP signature