Skip to content

Commit

Permalink
x86/boot: Fix memory leak in default_get_smp_config()
Browse files Browse the repository at this point in the history
When default_get_smp_config() is called with early == 1 and mpf->feature1
is non-zero, mpf is leaked because the return path does not do
early_memunmap().

Fix this and share a common exit routine.

Fixes: 5997efb ("x86/boot: Use memremap() to map the MPF and MPC data")
Reported-by: Cfir Cohen <[email protected]>
Signed-off-by: David Rientjes <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Cc: [email protected]
Link: https://lkml.kernel.org/r/[email protected]
  • Loading branch information
rientjes authored and KAGA-KOKO committed Jul 16, 2019
1 parent c7ca0b6 commit e74bd96
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions arch/x86/kernel/mpparse.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,17 +546,15 @@ void __init default_get_smp_config(unsigned int early)
* local APIC has default address
*/
mp_lapic_addr = APIC_DEFAULT_PHYS_BASE;
return;
goto out;
}

pr_info("Default MP configuration #%d\n", mpf->feature1);
construct_default_ISA_mptable(mpf->feature1);

} else if (mpf->physptr) {
if (check_physptr(mpf, early)) {
early_memunmap(mpf, sizeof(*mpf));
return;
}
if (check_physptr(mpf, early))
goto out;
} else
BUG();

Expand All @@ -565,7 +563,7 @@ void __init default_get_smp_config(unsigned int early)
/*
* Only use the first configuration found.
*/

out:
early_memunmap(mpf, sizeof(*mpf));
}

Expand Down

0 comments on commit e74bd96

Please sign in to comment.