Martin Roth has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/34249 )
Change subject: cpu/x86: Initialize the argument value msr_index ......................................................................
Patch Set 1:
(1 comment)
https://review.coreboot.org/c/coreboot/+/34249/1/src/cpu/x86/mtrr/mtrr.c File src/cpu/x86/mtrr/mtrr.c:
https://review.coreboot.org/c/coreboot/+/34249/1/src/cpu/x86/mtrr/mtrr.c@361 PS1, Line 361: ARRAY_SIZE(fixed_msrs) I think another way to fix this would be to use msr_num here and in the loop below. What the static analyzer is seeing, i believe, is that we might not go through the loop above the same number of times as the loop here and below, leading to the us to use the uninitialized variable. Changing the value to 0 will cause us to write out to MSR 0 if that ever happened.
If you want to stick with the meset, maybe add this to each loop to make sure we don't do that here?
if (msr_index[i] == 0) next;
What do you think?