Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10487292ybi; Thu, 25 Jul 2019 00:10:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqw/6/rxiNKP074U5hEG87GHxGdhWOjMtd9zAXmg4G0Bq5pR2hFaNvc4H89CwngaVGwX4gnK X-Received: by 2002:aa7:96ad:: with SMTP id g13mr15860011pfk.182.1564038627173; Thu, 25 Jul 2019 00:10:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564038627; cv=none; d=google.com; s=arc-20160816; b=tb/CWrzBMjBdhGNWCVbKaUB94X+b3KXsAUhPvigQlB0tJpxnmy0dr1gu9jh5YpkFDb fOXcQGS8xOHn7Hu/H6J7RfLnocO9xHkBkfVSyVAioxZoYcsQ7OHDfwbdy/txSJFgNtBD KRQJ+Ej65j2wBTT9ZqQWf9t4vbV0s2Q7BRTe7WVLRrBJOw4bG8cJMiEbeWOWm34O26Xy Ku0Hsvk+ZmzeTaAt/+HjeUKNPI7sDVriECcuQvI85oZ7PNTKTP8feINtMQYp9KVUlsa7 BJmFbscL4ehqFjgeb5enqF9ldymkonelqYcqmROKZPh0GkSPIEcGFm3/XzI9mtUor+gB I0/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vqqN7ZxVjIA4ihofDG0SMtWkfT6QXDUlaHggmiOLAX0=; b=q91wHk0dro3yVHQJOebJ/8pyQmliEzCQBtQAhNs35YIwkQ7iO2Mr7r7toCSc5MEClO vOGsYjp53IelYsOmFECszKtfT5SI4p9xFRfjEqZSckX0TrSv6hfztnFh4D6gDJUa3+Jm ogSuQbXCvL0fvu/qCR/EhVCZsQeP+iuYrs5R0FfAdbWFjSvDT7P0PPTAtUdMYNpAUH+E 5Zd7xyNsxWrd3LT1c39LGpZuMP61vZViU4zyIkGuu0zIPM8qrj+rFzD7OFJJPndIC4BG JB/NaE62VDwP6IRSA73NYD3+er0jDIBopEdszGMUWxWTvf8fRyAIkZmqF8V17EClJdjf 3K0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pr3kAIms; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s24si17868765pgq.372.2019.07.25.00.10.12; Thu, 25 Jul 2019 00:10:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pr3kAIms; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405096AbfGXT6g (ORCPT + 99 others); Wed, 24 Jul 2019 15:58:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:45106 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405088AbfGXT6d (ORCPT ); Wed, 24 Jul 2019 15:58:33 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8B49D206BA; Wed, 24 Jul 2019 19:58:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563998312; bh=umCl6dFR14+uVHcFjKurp7A+kE3J7+NoohuECceKeLg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pr3kAImsnppfwqfLAbLS6ZT+kQc1vHvq02/l7g1lrwHadbmKlXVtpcJ9MG0gdaLg3 Gujvftm1f7Iw4WazJv+A0LjSOUv6NdvSXwjaGygMRV7+z75HzqTBhI58eQb8331T8J toOhD218u2Bsgwb1wIAGLI33WkYVVm4hnNH0qzKY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Cfir Cohen , David Rientjes , Thomas Gleixner Subject: [PATCH 5.1 321/371] x86/boot: Fix memory leak in default_get_smp_config() Date: Wed, 24 Jul 2019 21:21:13 +0200 Message-Id: <20190724191748.088772676@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191724.382593077@linuxfoundation.org> References: <20190724191724.382593077@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Rientjes commit e74bd96989dd42a51a73eddb4a5510a6f5e42ac3 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: 5997efb96756 ("x86/boot: Use memremap() to map the MPF and MPC data") Reported-by: Cfir Cohen Signed-off-by: David Rientjes Signed-off-by: Thomas Gleixner Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/alpine.DEB.2.21.1907091942570.28240@chino.kir.corp.google.com Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/mpparse.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) --- a/arch/x86/kernel/mpparse.c +++ b/arch/x86/kernel/mpparse.c @@ -546,17 +546,15 @@ void __init default_get_smp_config(unsig * 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(); @@ -565,7 +563,7 @@ void __init default_get_smp_config(unsig /* * Only use the first configuration found. */ - +out: early_memunmap(mpf, sizeof(*mpf)); }