Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2606368yba; Fri, 10 May 2019 14:59:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqwXvkHZ8DnPUKkulZxv/TWLxOrOLHM57DPCEFzcjPlljMGLRn5ek9FmaXHRyscfcrFxcR9v X-Received: by 2002:a17:902:bcc6:: with SMTP id o6mr15277163pls.275.1557525575845; Fri, 10 May 2019 14:59:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557525575; cv=none; d=google.com; s=arc-20160816; b=Bp/9tE1aj7jr7qXgcokn38m+3rg8Vm2Ryj//WKvXhq8DWAw212UOJWVJ1X7Wu565o+ 9u5XuPx+8yWYQOsPmL7x35pX7ou+5VoSSul8J6wWAtSZv30ZHuKD5id+pNv9Ix/BPJUZ 8WgTnUxz2vpaZSh7H7Fpk29XHKx7pwHSygO9H1+mFq7W+4eJiCXeKYVskp8b+4MccjwS GSOtt7WZCjTX3cwigTz43vNsJG+Zc5ae9ApVSHCXwhRT3z7S+f2XHVADHRqzxgPl+754 6N7+6t6KHqyBjGhkpGtXlbIYAZTXQh5xaBMzgZQkkgvmTLzyWJCFBEX3jOHtJS3oWFxO Y8ZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:user-agent:message-id:to:cc:subject :from:references:in-reply-to:content-transfer-encoding:mime-version :dkim-signature; bh=Ht7ftENytry8iLdjfON93hG8IOVq7xHiHUNG0B8Cq0Y=; b=r/WTBaFFP27VQV++zwaMeHj9k26dhcb55EW5ucQ7a8WA/fISwT57dTJTCJZbVXSOU3 LpTUkQqeYIt/voR3aDSWS6nOd64MQXoG0kco6tVddr+gRkHSuozwC7a156woX5I52oJA i31xsWWaw8FqmNQGtE3asPja7IbXUbcUZF0JU7m/bjwbWb+ObET6CTSqy6WBErr+tzDT +OLSh33DBOyBeeEg3cbh1ASyB5Qgg6h1yv4POcXlIiugBVD885v2pIDBAQMZe/wxzaC2 pKxGDPmUEhcremNkRkHSHxyfqYPlCaQ24npDZY0qVLlkY9YS0weKCgW1OMNocxQFocKY SDpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="C/zZPD33"; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f17si10640746pfq.237.2019.05.10.14.59.19; Fri, 10 May 2019 14:59:35 -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=@chromium.org header.s=google header.b="C/zZPD33"; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728140AbfEJVYz (ORCPT + 99 others); Fri, 10 May 2019 17:24:55 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:41430 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727767AbfEJVYz (ORCPT ); Fri, 10 May 2019 17:24:55 -0400 Received: by mail-pg1-f196.google.com with SMTP id z3so3583190pgp.8 for ; Fri, 10 May 2019 14:24:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:content-transfer-encoding:in-reply-to:references:from :subject:cc:to:message-id:user-agent:date; bh=Ht7ftENytry8iLdjfON93hG8IOVq7xHiHUNG0B8Cq0Y=; b=C/zZPD33t+80hCt103zWOGGjxmmkR+8z+LazeEaU4ZX2PPxkLxNL29kA7CqI2lV+5M sqSL/uR8q7GIvD0drctcWk8CJ+nZb6xsbgD0rpNFc6kGLHjq9eBRh/WtvvPE67weo4yZ YOQxFcEG7iRU/w4JjmEUz0f0AaCozoEKzkVQE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:content-transfer-encoding :in-reply-to:references:from:subject:cc:to:message-id:user-agent :date; bh=Ht7ftENytry8iLdjfON93hG8IOVq7xHiHUNG0B8Cq0Y=; b=WU0lm5MC5I/jTS0e9WRG8KGf0uqRFDlWQ4ESlsv0zqmgwTFa8P6xHMw2wqfkgWgdCG ePYfn06Xw994A32gLbw67AXOLRUA8++lPiHm5AGgF7DS72gdfuHBy9NvMmXQ+xVx3R1F DqXoBMOXiJUGajik7B0yMu4Lpifx364aqP/W7YHoDru98VGbLBQgYhK/QCTT3StF7gEw KDvVqNpJP9wIajvhXCPuLIo0is+Tnb+tg1Y0rTk85MUYPd9dGdvrJdJB8CAY0PyxvA/5 sl3PIaBQRJekt7lUJXYqXvW529Fd/o0/oDkafiOdbDSzmgDeIXzrGVxbncyUhxNzVvAw i8Vw== X-Gm-Message-State: APjAAAV3BJVIZppgH3PuCC0swVq7BoL+XhKQNTIi/pOBwEhNuoJeOu4R 319v0YufTn3nCDRoKyrfr8AnERX4gCN4Lw== X-Received: by 2002:a63:4710:: with SMTP id u16mr5496241pga.447.1557523494573; Fri, 10 May 2019 14:24:54 -0700 (PDT) Received: from localhost ([2620:15c:202:1:fa53:7765:582b:82b9]) by smtp.gmail.com with ESMTPSA id i27sm17037346pfk.162.2019.05.10.14.24.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 10 May 2019 14:24:53 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <20190510180151.115254-3-swboyd@chromium.org> References: <20190510180151.115254-1-swboyd@chromium.org> <20190510180151.115254-3-swboyd@chromium.org> From: Stephen Boyd Subject: [PATCH v2 2/5] firmware: google: memconsole: Use devm_memremap() Cc: linux-kernel@vger.kernel.org, Wei-Ning Huang , Julius Werner , Brian Norris , Samuel Holland , Guenter Roeck To: Greg Kroah-Hartman Message-ID: <155752349303.14659.3560946140992031740@swboyd.mtv.corp.google.com> User-Agent: alot/0.8 Date: Fri, 10 May 2019 14:24:53 -0700 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use the devm version of memremap so that we can delete the unmapping code in driver remove, but more importantly so that we can unmap this memory region if memconsole_sysfs_init() errors out for some reason. Cc: Wei-Ning Huang Cc: Julius Werner Cc: Brian Norris Cc: Samuel Holland Cc: Guenter Roeck Signed-off-by: Stephen Boyd --- Quoting Stephen Boyd (2019-05-10 11:01:48) > diff --git a/drivers/firmware/google/memconsole-coreboot.c b/drivers/firm= ware/google/memconsole-coreboot.c > index 86331807f1d5..0b29b27b86f5 100644 > --- a/drivers/firmware/google/memconsole-coreboot.c > +++ b/drivers/firmware/google/memconsole-coreboot.c > @@ -85,7 +85,7 @@ static int memconsole_probe(struct coreboot_device *dev) > =20 > /* Read size only once to prevent overrun attack through /dev/mem= . */ > cbmem_console_size =3D tmp_cbmc->size_dont_access_after_boot; > - cbmem_console =3D memremap(dev->cbmem_ref.cbmem_addr, > + cbmem_console =3D devm_memremap(&dev->dev, dev->cbmem_ref.cbmem_a= ddr, Whoops, this returns an error pointer now. Here's an updated patch. drivers/firmware/google/memconsole-coreboot.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/firmware/google/memconsole-coreboot.c b/drivers/firmwa= re/google/memconsole-coreboot.c index 86331807f1d5..cc3797f1ba85 100644 --- a/drivers/firmware/google/memconsole-coreboot.c +++ b/drivers/firmware/google/memconsole-coreboot.c @@ -85,13 +85,13 @@ static int memconsole_probe(struct coreboot_device *dev) =20 /* Read size only once to prevent overrun attack through /dev/mem. */ cbmem_console_size =3D tmp_cbmc->size_dont_access_after_boot; - cbmem_console =3D memremap(dev->cbmem_ref.cbmem_addr, + cbmem_console =3D devm_memremap(&dev->dev, dev->cbmem_ref.cbmem_addr, cbmem_console_size + sizeof(*cbmem_console), MEMREMAP_WB); memunmap(tmp_cbmc); =20 - if (!cbmem_console) - return -ENOMEM; + if (IS_ERR(cbmem_console)) + return PTR_ERR(cbmem_console); =20 memconsole_setup(memconsole_coreboot_read); =20 @@ -102,9 +102,6 @@ static int memconsole_remove(struct coreboot_device *de= v) { memconsole_exit(); =20 - if (cbmem_console) - memunmap(cbmem_console); - return 0; } =20 base-commit: e93c9c99a629c61837d5a7fc2120cd2b6c70dbdd prerequisite-patch-id: b7c2a1e21fb108364f0e8cfaf1970cbc7903c750 --=20 Sent by a computer through tubes