Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1393731ybi; Tue, 16 Jul 2019 14:21:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqysCjGPq7/c4HvIaxYYoMJxp8yHpkxVoyXdd4l3SEN49xJ9ZdZH8s9b+lclNqtWuZJ5CJWo X-Received: by 2002:a63:6ec6:: with SMTP id j189mr37518151pgc.168.1563312110793; Tue, 16 Jul 2019 14:21:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563312110; cv=none; d=google.com; s=arc-20160816; b=h49WG14DmmUIIdK7yGyrDXrP/HmidG0ntkdgU/X9J6sZznh1CeLVgLre+mjJ5GQOr2 EkXVxL5AbCPeiK2VSVbDua1I2A27SSk0Hb4qWg8NdwPhztAtd6uJQjvlFA3Jm4iGRBaj f7Lcgzu5xKkv7zG/Zmby1FFuDgQsYRgYKJgtDMtDvvS6Tdr3Ec3vH5lJ04Bp763JiXyS 5R83BsTLhz5kEl1biTuHFKoVRJZMs0+SSirkbnLTdHPoIbyPKh8YIw4TICM9SKE3LpI5 faGhFxmRtuVQSx8URtWnHOc6aWKP+AbvLa1dJPe7QoAM0euoSIGIbleA5IUAw+PpgSyg KomA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:dkim-signature:dkim-filter; bh=1zfYUP/mfuxHi/RJzpFXhZa1Vfg52V/Ht743QSHKRdQ=; b=EABAdpppahWBm/YHicZVH95AhWzloYCa8KipnTMrA4NEML1muUdInqo0se45wD2opS tu2TL2rOOdH2WRWCqFGPrdIXZjWw9vQouJxY0Xjanhzf8I54witl8hjMFIHeFytlL4Xv 943h67Z+cWgi50FTETZ2tHoF3HPyibTEhh6TaPYvZje0ZA1O9B9plnro8k9pX7iOdD4P 4HvHM6+ol6fHG8rnw97rWWLaHXjqh4nm6zC3pV/cE72zdHg5o25V87IIIXph8BQP435j Kwi0LA5Dtp7eXOkQszmWYYlThQv/TrPUEZIvUp4J+i+RyfFFpgL2nBjl6Rk972wVsUkY 3BpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2019061801 header.b=tk4fKsUI; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k137si20839627pga.59.2019.07.16.14.21.35; Tue, 16 Jul 2019 14:21:50 -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=@zytor.com header.s=2019061801 header.b=tk4fKsUI; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732696AbfGPVT0 (ORCPT + 99 others); Tue, 16 Jul 2019 17:19:26 -0400 Received: from terminus.zytor.com ([198.137.202.136]:43097 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728118AbfGPVTZ (ORCPT ); Tue, 16 Jul 2019 17:19:25 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x6GLJCuA1229585 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Tue, 16 Jul 2019 14:19:12 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 terminus.zytor.com x6GLJCuA1229585 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2019061801; t=1563311953; bh=1zfYUP/mfuxHi/RJzpFXhZa1Vfg52V/Ht743QSHKRdQ=; h=Date:From:Cc:Reply-To:In-Reply-To:References:To:Subject:From; b=tk4fKsUIgP+bP4teuGpz//u8HWLVnt4LTxcierqyTAKZbNxNh5g0prrYBOR891O+t ylzErAOHedYvOhVi6oJBuZqRBDi7uUIN/ZIJKQOOy5uf9nFY1US5DrEwkJvrcGM47j yvsUqaGcL3s0/0y13nlyileqcS8nRcjJluBYBaxxajhGDaFxVGufxJfymak6QYCPmj 8J8J+UB4fEGdg4hSmL0BpZQCdqsOxZDR+gyOd9L49jknEZzxRnyvkq3HtN32MhvN4v DhC7OGAG0gogUW6ZGwVYdps875t84WCe4CQrgDnhChVgBFwt+HW6Ks8MkTNSehQiNl eyW1Pz4z4SzMA== Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x6GLJCj81229582; Tue, 16 Jul 2019 14:19:12 -0700 Date: Tue, 16 Jul 2019 14:19:12 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for David Rientjes Message-ID: Cc: tglx@linutronix.de, cfir@google.com, linux-kernel@vger.kernel.org, mingo@kernel.org, rientjes@google.com, hpa@zytor.com Reply-To: tglx@linutronix.de, cfir@google.com, linux-kernel@vger.kernel.org, rientjes@google.com, mingo@kernel.org, hpa@zytor.com In-Reply-To: References: To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/urgent] x86/boot: Fix memory leak in default_get_smp_config() Git-Commit-ID: e74bd96989dd42a51a73eddb4a5510a6f5e42ac3 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-1.1 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_24_48,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU, DKIM_VALID_EF autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: e74bd96989dd42a51a73eddb4a5510a6f5e42ac3 Gitweb: https://git.kernel.org/tip/e74bd96989dd42a51a73eddb4a5510a6f5e42ac3 Author: David Rientjes AuthorDate: Tue, 9 Jul 2019 19:44:03 -0700 Committer: Thomas Gleixner CommitDate: Tue, 16 Jul 2019 23:13:48 +0200 x86/boot: Fix memory leak in default_get_smp_config() 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 --- arch/x86/kernel/mpparse.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/mpparse.c b/arch/x86/kernel/mpparse.c index 1bfe5c6e6cfe..afac7ccce72f 100644 --- a/arch/x86/kernel/mpparse.c +++ b/arch/x86/kernel/mpparse.c @@ -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(); @@ -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)); }