Bug 215719

Summary: gcc (GCC) 11.2.0 reports logical error
Product: Drivers Reporter: Erich Löw (Erich.Loew)
Component: Flash/Memory Technology DevicesAssignee: David Woodhouse (dwmw2)
Status: NEW ---    
Severity: normal CC: Erich.Loew, regressions
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 5.17 Subsystem:
Regression: No Bisected commit-id:

Description Erich Löw 2022-03-21 19:45:45 UTC
Module:   linux-5.17/drivers/mtd/nand/raw/nand_base.c
Function: nand_match_ecc_req()
Observation: compiler exits with error because local variables 
             best_step and best_ecc_bytes are not pre-initialized to "0".
Root cause:  if the for loop is not executed the record entries
chip->ecc.size and chip->ecc.bytes will be initialized with random stack
values.
This leads to unpredictable mal-function of the function caller.

Interesting: clang-15.0.0 is not complaining
Comment 1 The Linux kernel's regression tracker (Thorsten Leemhuis) 2022-03-30 13:56:59 UTC
Is this already in earlier kernels like 5.16 or new in 5.17?
Comment 2 Erich Löw 2022-12-24 10:34:45 UTC
I use in meantime kernel 6.1.1. and topic is likely gone.
My mitigation to get freed from the many warnings if compiling 
with "gcc (GCC) 13.0.0" and/or clang version 16.0.0:
--> Commenting out "KBUILD_CFLAGS-$(CONFIG_WERROR) += -Werror"
With kernel 6.1.1 the -Werror instruction can stay active and no warnings popping up.