Skip to content

Commit 41f1230

Browse files
Nikolay Borisovgregkh
authored andcommitted
x86/microcode/AMD: Return bool from find_blobs_in_containers()
commit a85c08a upstream. Instead of open-coding the check for size/data move it inside the function and make it return a boolean indicating whether data was found or not. No functional changes. [ bp: Write @ret in find_blobs_in_containers() only on success. ] Signed-off-by: Nikolay Borisov <nik.borisov@suse.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Link: https://lore.kernel.org/r/20241018155151.702350-2-nik.borisov@suse.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b0f47c8 commit 41f1230

File tree

1 file changed

+9
-6
lines changed
  • arch/x86/kernel/cpu/microcode

1 file changed

+9
-6
lines changed

arch/x86/kernel/cpu/microcode/amd.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -569,14 +569,19 @@ static bool get_builtin_microcode(struct cpio_data *cp)
569569
return false;
570570
}
571571

572-
static void __init find_blobs_in_containers(struct cpio_data *ret)
572+
static bool __init find_blobs_in_containers(struct cpio_data *ret)
573573
{
574574
struct cpio_data cp;
575+
bool found;
575576

576577
if (!get_builtin_microcode(&cp))
577578
cp = find_microcode_in_initrd(ucode_path);
578579

579-
*ret = cp;
580+
found = cp.data && cp.size;
581+
if (found)
582+
*ret = cp;
583+
584+
return found;
580585
}
581586

582587
void __init load_ucode_amd_bsp(struct early_load_data *ed, unsigned int cpuid_1_eax)
@@ -591,8 +596,7 @@ void __init load_ucode_amd_bsp(struct early_load_data *ed, unsigned int cpuid_1_
591596
/* Needed in load_microcode_amd() */
592597
ucode_cpu_info[0].cpu_sig.sig = cpuid_1_eax;
593598

594-
find_blobs_in_containers(&cp);
595-
if (!(cp.data && cp.size))
599+
if (!find_blobs_in_containers(&cp))
596600
return;
597601

598602
if (early_apply_microcode(ed->old_rev, cp.data, cp.size))
@@ -612,8 +616,7 @@ static int __init save_microcode_in_initrd(void)
612616
if (dis_ucode_ldr || c->x86_vendor != X86_VENDOR_AMD || c->x86 < 0x10)
613617
return 0;
614618

615-
find_blobs_in_containers(&cp);
616-
if (!(cp.data && cp.size))
619+
if (!find_blobs_in_containers(&cp))
617620
return -EINVAL;
618621

619622
scan_containers(cp.data, cp.size, &desc);

0 commit comments

Comments
 (0)