From patchwork Thu Oct 4 13:31:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda Delgado X-Patchwork-Id: 978907 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="JjnICHZr"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Bs1dYuEw"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42Qv2D1hWxz9s8J for ; Thu, 4 Oct 2018 23:32:20 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=wlyA5tjT+rUODPRAmPl8diqwQyVygXruRql3UGgRXQk=; b=JjnICHZr4eJ0Y3 RPf8SMXT+MsrHxvAgbI7EqgWnw6tIoC/sBUFKu4kEfi7F6z+AgiQPIcOju343juT2MgIabG498Tn1 zXBPH9gHbtvQTQPa+jwkL/4gevFp654sqOsqxo0iL1YEj/ayuSwSWg+KOk1KoEr/exE9e61NbH9FG QMvu5nGVJ60Av7sOmFqrj1y90xN9+9qBZq0KKgS4Lc+VxECGxQ1SZoQHApBr4rF7+UeEr0UQxDX7G Obnzn6NRTyi0qUkR/0oxK3MzFEboJ6MnKFu01rb9TAAKuInS01FhFCZwKhBmC8P1MvMCQwziIPisq zxV93ZjLL0/RJ+Js1ccQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g83jc-0007YA-LH; Thu, 04 Oct 2018 13:32:08 +0000 Received: from mail-ed1-x541.google.com ([2a00:1450:4864:20::541]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g83jY-0007Wv-AS for linux-mtd@lists.infradead.org; Thu, 04 Oct 2018 13:32:05 +0000 Received: by mail-ed1-x541.google.com with SMTP id b7-v6so1982064edd.9 for ; Thu, 04 Oct 2018 06:31:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=raX5qEj7fRXQ/iQULa01jf7rlvPVsAVNG0zX/XpZs5g=; b=Bs1dYuEw88RWdvlU/QKrnpxanvvHnNSDQFMCUNnhGfgzRk38FPRYfrPXesa9G65Oje fwRe9wYuwkFuMHMbDQVywWy0puErljO1BsdC14RW/NNTvwxWb8BfhHufi/Mu1zGHoLYQ XshtXDFHCNh6FQG9vZr3wBdxltd7ojT5Unb5R+5qLKhZgvqIsFpGjlwdYbC2Eum7HiIH 8aXlt8Ar4pCksyzMcwMdxcBJw5zGPfWZuLsjLjKqhniXvfjB6uU2uOECG84l4wNSln0I lw/LGF0zTqdtpiC3FODvL+vXK4M03SA7WeNws9RfG/dbLQZ+f4+YXFBCEqvhAkU3mhjQ pOqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=raX5qEj7fRXQ/iQULa01jf7rlvPVsAVNG0zX/XpZs5g=; b=rwZ8W6jhiQ76mhHLxl5vwextGibizQriVlH696Q6aWor0r9jlzT7YiGRQWaLYa7rlb qJQ/bZlYows+wfEJdkeubo/MZnuKueiJpfVIbXCpAck6md88Gpw7Bwda1mqts53HohRg Vl6ekN1xm+pqwBqPgfzy3efGoxwa4MxBym/HGY2+u1a9Uk/DvSlUkUm+RdrSXy6CtXrF AyVR8j7z1wKPaJAGwsEUQnPw2pPC7XkShGLGpiWFaGneI2HSTaSY0dl8GFa944IYhanI r013MzTD0gIDmCSEHe4EN6UFJv/VY1g46kXV4C43XsxVMd/5W7ajC8nipYjeVi2ZbE4W 7ozw== X-Gm-Message-State: ABuFfoh+PZvY7BpET2kh0J8tnR4rVO/i080PkPmGDbSCwmqUgSeb0gFf civr0F4tbyb+I8Ywk0qf+ufFHF6U X-Google-Smtp-Source: ACcGV62M0y9IvVduVqMidTLJ3pwy/KabW35fThv4AnQreLY6qMvmNnSKU/FK3nSUQoaLDqFSS28euA== X-Received: by 2002:a50:8a96:: with SMTP id j22-v6mr8461277edj.189.1538659910169; Thu, 04 Oct 2018 06:31:50 -0700 (PDT) Received: from neopili.qtec.com (cpe.xe-3-0-1-778.vbrnqe10.dk.customer.tdc.net. [80.197.57.18]) by smtp.gmail.com with ESMTPSA id c24-v6sm1440569ede.73.2018.10.04.06.31.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Oct 2018 06:31:49 -0700 (PDT) From: Ricardo Ribalda Delgado To: David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut , Richard Weinberger , Zhouyang Jia , linux-mtd@lists.infradead.org, open list Subject: [PATCH v8 01/10] mtd: physmap_of: Release resources on error Date: Thu, 4 Oct 2018 15:31:46 +0200 Message-Id: <20181004133147.20215-1-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181004_063204_391562_A7A9B432 X-CRM114-Status: GOOD ( 16.84 ) X-Spam-Score: -0.1 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:541 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (ricardo.ribalda[at]gmail.com) -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ricardo Ribalda Delgado Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org During probe, if there was an error the memory region and the memory map were not properly released.This can lead a system unusable if deferred probe is in use. Replace mem_request and map with devm_ioremap_resource Signed-off-by: Ricardo Ribalda Delgado --- drivers/mtd/maps/physmap_of_core.c | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/drivers/mtd/maps/physmap_of_core.c b/drivers/mtd/maps/physmap_of_core.c index 4129535b8e46..ed75f1781c37 100644 --- a/drivers/mtd/maps/physmap_of_core.c +++ b/drivers/mtd/maps/physmap_of_core.c @@ -31,7 +31,6 @@ struct of_flash_list { struct mtd_info *mtd; struct map_info map; - struct resource *res; }; struct of_flash { @@ -56,18 +55,10 @@ static int of_flash_remove(struct platform_device *dev) mtd_concat_destroy(info->cmtd); } - for (i = 0; i < info->list_size; i++) { + for (i = 0; i < info->list_size; i++) if (info->list[i].mtd) map_destroy(info->list[i].mtd); - if (info->list[i].map.virt) - iounmap(info->list[i].map.virt); - - if (info->list[i].res) { - release_resource(info->list[i].res); - kfree(info->list[i].res); - } - } return 0; } @@ -215,10 +206,11 @@ static int of_flash_probe(struct platform_device *dev) err = -EBUSY; res_size = resource_size(&res); - info->list[i].res = request_mem_region(res.start, res_size, - dev_name(&dev->dev)); - if (!info->list[i].res) + info->list[i].map.virt = devm_ioremap_resource(&dev->dev, &res); + if (IS_ERR(info->list[i].map.virt)){ + err = PTR_ERR(info->list[i].map.virt); goto err_out; + } err = -ENXIO; width = of_get_property(dp, "bank-width", NULL); @@ -246,15 +238,6 @@ static int of_flash_probe(struct platform_device *dev) if (err) goto err_out; - err = -ENOMEM; - info->list[i].map.virt = ioremap(info->list[i].map.phys, - info->list[i].map.size); - if (!info->list[i].map.virt) { - dev_err(&dev->dev, "Failed to ioremap() flash" - " region\n"); - goto err_out; - } - simple_map_init(&info->list[i].map); /*