Commit 7a45c683 authored by David Rientjes's avatar David Rientjes Committed by Greg Kroah-Hartman

x86/boot: Fix memory leak in default_get_smp_config()

commit e74bd969 upstream.

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: 5997efb9 ("x86/boot: Use memremap() to map the MPF and MPC data")
Reported-by: default avatarCfir Cohen <cfir@google.com>
Signed-off-by: default avatarDavid Rientjes <rientjes@google.com>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
Link: https://lkml.kernel.org/r/alpine.DEB.2.21.1907091942570.28240@chino.kir.corp.google.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent bbe75669
...@@ -546,17 +546,15 @@ void __init default_get_smp_config(unsigned int early) ...@@ -546,17 +546,15 @@ void __init default_get_smp_config(unsigned int early)
* local APIC has default address * local APIC has default address
*/ */
mp_lapic_addr = APIC_DEFAULT_PHYS_BASE; mp_lapic_addr = APIC_DEFAULT_PHYS_BASE;
return; goto out;
} }
pr_info("Default MP configuration #%d\n", mpf->feature1); pr_info("Default MP configuration #%d\n", mpf->feature1);
construct_default_ISA_mptable(mpf->feature1); construct_default_ISA_mptable(mpf->feature1);
} else if (mpf->physptr) { } else if (mpf->physptr) {
if (check_physptr(mpf, early)) { if (check_physptr(mpf, early))
early_memunmap(mpf, sizeof(*mpf)); goto out;
return;
}
} else } else
BUG(); BUG();
...@@ -565,7 +563,7 @@ void __init default_get_smp_config(unsigned int early) ...@@ -565,7 +563,7 @@ void __init default_get_smp_config(unsigned int early)
/* /*
* Only use the first configuration found. * Only use the first configuration found.
*/ */
out:
early_memunmap(mpf, sizeof(*mpf)); early_memunmap(mpf, sizeof(*mpf));
} }
......
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