Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3477640imu; Sun, 11 Nov 2018 16:01:23 -0800 (PST) X-Google-Smtp-Source: AJdET5fnPykx4nhlf94wUQM9z0uYM0MVhd2YNvO8csW+aFxUsUBps4MUTwLYnarHxSSJF75EeNmX X-Received: by 2002:a62:5210:: with SMTP id g16-v6mr17873464pfb.256.1541980883782; Sun, 11 Nov 2018 16:01:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541980883; cv=none; d=google.com; s=arc-20160816; b=ZIsksFclgCSwSZnOTf8DgREcnFUfd6OExDr4cgM3OUcO2Gw+iKCnCJliEkhIOxwzgc mSmeYTGpq8eUWmGC/TjRMWVRqOrPO3S5lkvJWtbXmSUT0IQZ4qEwWygAuIF1aBoMzbKq 2NfmxMNbhYDgTg6TceHlvheKeCp+0yRddDsCB88onCW3gfNPp3qkqIinp+yJx4P+v7FZ 7SLr794Br5GHELH/cs+OteLIUkAPqOBi4dwMI0i4SHzd7Ym4B5O6N8A3j9IritMRBWca Ss9hSNnBfkqfHNXQnWDPKogRtBbjbVzEcd6egudlASmPsBpylrUCefetXInx/REPTpjR 2akg== 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=xro3Q1p4yZthob7t1Llt69tJY7OfNTBuuIFH60Khwyw=; b=zkWLcneWQ+imeszJSXOeuIbHbJHh/PVWq9hWeYFx95if6fbrfAxg91qJJD3tNDZQgs 8oa4I3cn5ieF98JpXZlLQRSQVdcUJXdq4jaTs+gRoNnNJltNp7QSExCRLHBUU9wITGQs HVj8GAv6CSXvj4e1Nc0UkCfCqzDbiC1ZB84gp9/F5OPCueWf5lxj5Nt++OwRbgjsXiA+ +x4Xzun8oGYOof5SRhGuPGQG+xW9YGnlHvIzRu4TTxkz8PAhhKKwM11MQpAnryzEmCGj VOX4i4ylQEtNa/31m2HxEKiwa4kB8KDNAe6O48u2d6o6yOmidvhoB6YH/AZcDDAn0eac 9/jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Dyce76yt; 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 h3-v6si15683718plb.291.2018.11.11.16.01.07; Sun, 11 Nov 2018 16:01:23 -0800 (PST) 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=Dyce76yt; 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 S1732445AbeKLJvL (ORCPT + 99 others); Mon, 12 Nov 2018 04:51:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:35336 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732255AbeKLIR7 (ORCPT ); Mon, 12 Nov 2018 03:17:59 -0500 Received: from localhost (unknown [206.108.79.134]) (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 1003F223CA; Sun, 11 Nov 2018 22:28:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975284; bh=CY7S1lRzubXHb9rrMbx9cAUpUmp0ZQuwaaCaxgUxxfs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dyce76yt+MvEclW/eelBfyB19ymasdGkARQo4CENldLmwtYupZffysYl6X7JHQ9v3 ErktdsOK0daBW2DeJdc6+HsRhgedG9UEzetnq4W5mnc6td9TtPHU66C9X5NNNIsk2T haDLTf0J/ekx50A80W7nYvU/pXdN37CqXzwYamuQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wei-Ning Huang , Julius Werner , Brian Norris , Samuel Holland , Stephen Boyd , Sasha Levin Subject: [PATCH 4.19 177/361] firmware: coreboot: Unmap ioregion after device population Date: Sun, 11 Nov 2018 14:18:44 -0800 Message-Id: <20181111221645.074251635@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ 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 Signed-off-by: Greg Kroah-Hartman --- drivers/firmware/google/coreboot_table.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/drivers/firmware/google/coreboot_table.c +++ b/drivers/firmware/google/coreboot_table.c @@ -110,7 +110,8 @@ int coreboot_table_init(struct device *d 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 *d 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; }