Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp701783imj; Wed, 13 Feb 2019 16:04:05 -0800 (PST) X-Google-Smtp-Source: AHgI3IZzEGj3TeDO5CO9WQbDf9mEUp2HuuyKej5FuSgsIZiOxgMQ0n2HpTQTlmgvkZBtRpqntFll X-Received: by 2002:a65:4bcd:: with SMTP id p13mr845956pgr.422.1550102645778; Wed, 13 Feb 2019 16:04:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550102645; cv=none; d=google.com; s=arc-20160816; b=gzbbTTFMw6OAf/ZijUvV4ytNd/2NvM4ZYEcCX9nn9sew9d/fAk1nLQf++6YIoZU5SX cGgmTYo9BSSh/Q4fwpawJLBa+/ZJgUWkXn1CuDyZ3Uzsh+KGtmBXKCAYMN6IHJjGERgB g7XbKuh325KiwdRSqdCp19DF1B7PdXGHS5QkKV4TanQDZfXStXi6OFh4O17dheatdsOA fsgayPP6ILWqhq8Hxm8zOqEwhLYiXSGh+f+D/13EMbhusmcPdx8/MJa1AL3hDbUImakT 0J9ECvZLc8fVBHyeoIYmvgkfOFxKo/TogqAmcxz2iR/UdIxXj3jFhg10W0jC8CP4M/xt rPYw== 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=sU+6AFn7YgOCJoeP8p9EmcwB4ucEBfOfZZQQ2p4JvzU=; b=ksrCjDpbVMf0bqP/TOLL/VYKE5gbabxhNJuca+Jsh6j4w0eM6JRx88DB4s/x/97UIQ TmGMuZRB0kUaxBYaXwx00NaMORaclqF9CAxl5ePieI/Izc6tA91axxu5LCMqSZ/kHnHr 6zylIqvmwk09V84WVYa+qpGRaqv0F+hGyOIm19NiZGMoA53KNZysHueGh9/sc96iO4sN E9hP+LXzqlfIwFmXjZKWhmS/HwiPPg6oYGwXw8WP1WRbfp44PE8bZVT7ZQ5pjW2TEN4Z CZLFIzaeCZPUWSyFBynvK+kPOq6WmMqaAWRS0qNCrAeUUSNyhCl/bxl1fxl49c5XpLtM fBbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=R16Y+ZkT; 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 q17si665286pgv.426.2019.02.13.16.03.49; Wed, 13 Feb 2019 16:04:05 -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=R16Y+ZkT; 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 S2405698AbfBMSmf (ORCPT + 99 others); Wed, 13 Feb 2019 13:42:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:41026 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405649AbfBMSmd (ORCPT ); Wed, 13 Feb 2019 13:42:33 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 5EC9F222D9; Wed, 13 Feb 2019 18:42:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550083352; bh=njhlwNr/4tc5cWJiGJahpXAWfSSU9VyI4LIEf2X6Ve0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R16Y+ZkTnCo/AK/6cFdSXrK6mI+ANvW7DiToHi8NWXdLEAkce5ry8eyQQuIi67C0C NZPg1ny9E+27ijZEz/30sJKBL4Y0YhBCuz+PQLsgXEYx3t9Af7L/WM2QNaxBkSEHoh xWws8wBiXM0pcQUgUxHubACHhnxp5y5CNkxyi8K4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Geert Uytterhoeven , Boris Brezillon , Geert Uytterhoeven Subject: [PATCH 4.19 01/44] mtd: Make sure mtd->erasesize is valid even if the partition is of size 0 Date: Wed, 13 Feb 2019 19:38:02 +0100 Message-Id: <20190213183651.764150579@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190213183651.648060257@linuxfoundation.org> References: <20190213183651.648060257@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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: Boris Brezillon commit ad4635153034c20c6f6e211e2ed3fd38b658649a upstream. Commit 33f45c44d68b ("mtd: Do not allow MTD devices with inconsistent erase properties") introduced a check to make sure ->erasesize and ->_erase values are consistent with the MTD_NO_ERASE flag. This patch did not take the 0 bytes partition case into account which can happen when the defined partition is outside the flash device memory range. Fix that by setting the partition erasesize to the parent erasesize. Fixes: 33f45c44d68b ("mtd: Do not allow MTD devices with inconsistent erase properties") Reported-by: Geert Uytterhoeven Cc: Cc: Geert Uytterhoeven Signed-off-by: Boris Brezillon Tested-by: Geert Uytterhoeven Signed-off-by: Greg Kroah-Hartman --- drivers/mtd/mtdpart.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c @@ -470,6 +470,10 @@ static struct mtd_part *allocate_partiti /* let's register it anyway to preserve ordering */ slave->offset = 0; slave->mtd.size = 0; + + /* Initialize ->erasesize to make add_mtd_device() happy. */ + slave->mtd.erasesize = parent->erasesize; + printk(KERN_ERR"mtd: partition \"%s\" is out of reach -- disabled\n", part->name); goto out_register;