Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp170316imd; Wed, 31 Oct 2018 16:44:18 -0700 (PDT) X-Google-Smtp-Source: AJdET5cFY7Q1W/w9Upr1MXPnsuo4xUXAhe5XDr1HWNfKPSq5UkhU1yIuvxxJZ5f+kE66IecLYpsr X-Received: by 2002:a17:902:2468:: with SMTP id m37-v6mr5423190plg.154.1541029458609; Wed, 31 Oct 2018 16:44:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541029458; cv=none; d=google.com; s=arc-20160816; b=uYxX7h/FCo49uTSQwjZ7jOV0JolFGxcB88DaEz6XEhcLRL0/hasGx4gXPn5+2fsVD0 s5UaOnaBwF7TGfbK739EcdmXjJVggjasOu07BpXUHy0NZOT+VqtW2YSjy0ZDqkVM9YUh Rk9G52G2bh2HemdFyXyKXmiJnYKJL57HWvagFT/phfgfApselvlLxQD/AoYvjq2TncCc dIwW3U0M2FNWHEQLH754GmIewktg2OrcKfYAEtOTrf/xtEKoN6X/EHD7YCv/XyrtMWik xdQ8svbQvBMHBZaEFrd+xvxXw+i0F9BsLAJi7N3/KnUIQ7mpkqWVTFqZNWpLvnc1+sU3 aOgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=nymrY/UykMz5D1G3hbddjAGUN5FWiIssorpuZApX2NI=; b=Wlt0UjuVMYQzl8sdtyGlpGsxUPK248YeAkgCTr/iRoxSw7Odkhnc0SMjwnGvsCzUgb IgW/v6TAd8JEZQwkeNWJmglHOsphB9f5WioLHYUbBCPO0Isqj6SCWNWKHEp1ETHRqjdN dM4Pxbp0cMiavWE3IwxuhDx0nMvnlSms7Y7t4+opWbVzFwYCDQptBOvJ7nznq81HLHMm Woh9vLysU5jHWk4gXerZTXgL3jVJveCgnmfeV1L4hR2RRbeloIu+bIwFHHxjfGAMdB3Q pRdYtUKPoB4M8IeXLH7L7plQ4HdVae+PEoTMcNPjL0tuqSwTxgCs+LTh50aG4u3YnfH3 39Vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JfXLj+Yd; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f6-v6si26608674plt.346.2018.10.31.16.44.03; Wed, 31 Oct 2018 16:44:18 -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=JfXLj+Yd; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729277AbeKAIHy (ORCPT + 99 others); Thu, 1 Nov 2018 04:07:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:56098 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729243AbeKAIHx (ORCPT ); Thu, 1 Nov 2018 04:07:53 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1DDE620821; Wed, 31 Oct 2018 23:07:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027262; bh=uj7pqy00sEesVJHROTkKHccFKi6NjlaVwUz+BnUtPmY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JfXLj+Yd3G1KBAuK+jNBPusBs2sXaVCgmHMEbZ8wQIbKi+50YU2zbpZppYq/782HI /HqFxOAFEG8+F6zeqIuo+7QzJA9mcNlnHGb/4DKAh4grwIdHGMzUZ/3z8Rzt3Etqr1 42T4u6f+sZ8kUfXP4WNkm+SRfzDlJ/tx3n46eXjY= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Stephen Boyd , Wei-Ning Huang , Julius Werner , Brian Norris , Samuel Holland , Greg Kroah-Hartman , Sasha Levin Subject: [PATCH AUTOSEL 4.19 133/146] firmware: coreboot: Unmap ioregion after device population Date: Wed, 31 Oct 2018 19:05:28 -0400 Message-Id: <20181031230541.28822-133-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031230541.28822-1-sashal@kernel.org> References: <20181031230541.28822-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stephen Boyd [ Upstream commit 20edec388277b62ddfddb8b2b376a937a2cd6d1b ] Both callers of coreboot_table_init() ioremap the pointer that comes in but they don't unmap the memory on failure. Both of them also fail probe immediately with the return value of coreboot_table_init(), leaking a mapping when it fails. The mapping isn't necessary at all after devices are populated either, so we can just drop the mapping here when we exit the function. Let's do that to simplify the code a bit and plug the leak. Cc: Wei-Ning Huang Cc: Julius Werner Cc: Brian Norris Cc: Samuel Holland Fixes: 570d30c2823f ("firmware: coreboot: Expose the coreboot table as a bus") Signed-off-by: Stephen Boyd Reviewed-by: Julius Werner Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/firmware/google/coreboot_table.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/google/coreboot_table.c b/drivers/firmware/google/coreboot_table.c index 19db5709ae28..898bb9abc41f 100644 --- a/drivers/firmware/google/coreboot_table.c +++ b/drivers/firmware/google/coreboot_table.c @@ -110,7 +110,8 @@ int coreboot_table_init(struct device *dev, void __iomem *ptr) if (strncmp(header.signature, "LBIO", sizeof(header.signature))) { pr_warn("coreboot_table: coreboot table missing or corrupt!\n"); - return -ENODEV; + ret = -ENODEV; + goto out; } ptr_entry = (void *)ptr_header + header.header_bytes; @@ -137,7 +138,8 @@ int coreboot_table_init(struct device *dev, void __iomem *ptr) ptr_entry += entry.size; } - +out: + iounmap(ptr); return ret; } EXPORT_SYMBOL(coreboot_table_init); @@ -146,7 +148,6 @@ int coreboot_table_exit(void) { if (ptr_header) { bus_unregister(&coreboot_bus_type); - iounmap(ptr_header); ptr_header = NULL; } -- 2.17.1