Commit c868570e authored by Borislav Petkov's avatar Borislav Petkov

x86/microcode/intel: Sanitize _save_mc()

Shorten local variable names for better readability and flatten loop
indentation levels.

No functionality change.
Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
parent a5de5e24
...@@ -268,39 +268,36 @@ save_microcode(struct mc_saved_data *mc_saved_data, ...@@ -268,39 +268,36 @@ save_microcode(struct mc_saved_data *mc_saved_data,
static unsigned int _save_mc(struct microcode_intel **mc_saved, static unsigned int _save_mc(struct microcode_intel **mc_saved,
u8 *ucode_ptr, unsigned int num_saved) u8 *ucode_ptr, unsigned int num_saved)
{ {
struct microcode_header_intel *mc_header; struct microcode_header_intel *mc_hdr, *mc_saved_hdr;
unsigned int sig, pf, new_rev;
int found = 0, i; int found = 0, i;
mc_header = (struct microcode_header_intel *)ucode_ptr; mc_hdr = (struct microcode_header_intel *)ucode_ptr;
for (i = 0; i < num_saved; i++) { for (i = 0; i < num_saved; i++) {
unsigned int sig, pf; mc_saved_hdr = (struct microcode_header_intel *)mc_saved[i];
unsigned int new_rev; sig = mc_saved_hdr->sig;
struct microcode_header_intel *mc_saved_header = pf = mc_saved_hdr->pf;
(struct microcode_header_intel *)mc_saved[i]; new_rev = mc_hdr->rev;
sig = mc_saved_header->sig;
pf = mc_saved_header->pf; if (!get_matching_sig(sig, pf, ucode_ptr, new_rev))
new_rev = mc_header->rev; continue;
if (get_matching_sig(sig, pf, ucode_ptr, new_rev)) {
found = 1; found = 1;
if (update_match_revision(mc_header, new_rev)) {
if (!update_match_revision(mc_hdr, new_rev))
continue;
/* /*
* Found an older ucode saved before. * Found an older ucode saved earlier. Replace it with
* Replace the older one with this newer * this newer one.
* one.
*/ */
mc_saved[i] = (struct microcode_intel *)ucode_ptr; mc_saved[i] = (struct microcode_intel *)ucode_ptr;
break; break;
} }
}
}
/* Newly detected microcode, save it to memory. */
if (i >= num_saved && !found) if (i >= num_saved && !found)
/*
* This ucode is first time discovered in ucode file.
* Save it to memory.
*/
mc_saved[num_saved++] = (struct microcode_intel *)ucode_ptr; mc_saved[num_saved++] = (struct microcode_intel *)ucode_ptr;
return num_saved; return num_saved;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment