Bug 215719 - gcc (GCC) 11.2.0 reports logical error
Summary: gcc (GCC) 11.2.0 reports logical error
Status: NEW
Alias: None
Product: Drivers
Classification: Unclassified
Component: Flash/Memory Technology Devices (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: David Woodhouse
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-03-21 19:45 UTC by Erich Löw
Modified: 2022-12-24 10:34 UTC (History)
2 users (show)

See Also:
Kernel Version: 5.17
Subsystem:
Regression: No
Bisected commit-id:


Attachments

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.

Note You need to log in before you can comment on or make changes to this bug.