Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp716079imj; Wed, 13 Feb 2019 16:23:15 -0800 (PST) X-Google-Smtp-Source: AHgI3IYHc2x3pjF1EMrmkIEzcwHfgyVlj9j1miqn2XRqI3opSYmsI5hzWeCHfXjnJo0w0+3L7vpI X-Received: by 2002:a17:902:704b:: with SMTP id h11mr989721plt.157.1550103795068; Wed, 13 Feb 2019 16:23:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550103795; cv=none; d=google.com; s=arc-20160816; b=E2DDIbYimVZZXFQ+d+0jtcV+LyuhiWuFbYQlGuhvpOsXTDgaFQq75KN8klesWv9yAg aIAt1lxtNQ/DpxN/IzOfTyvyhwvfbwuaZPi64kCv6p5uMnGpEDOx+4BxpRfBd0Z1YwaW caFUPSamFWAYHnPXZfMN8yqO6Kxb56Vn60EPhVRKpR9l0vLhP+f304Zg/QFmBEJr82iA kNDiYYQbAFjf3Z2mFW+RtUty8p3fWA5ORmV1fliefjBBs64zIykvMlsEIsIHC/wgKyYs gg9BZ7OPgte0RKxwEKFbov5fdSilj88PY213wcpSkpGl9Dervdd+rproksJnV2esiPla kLJA== 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=L9eK7RSwq7WxXWTY78C4HsFAR50tReB+P45YkFmgxQc=; b=ayKyvDte7Hx4OPgSprsINXjhSCt+U+uTHy2bC9RTJ/0DeUz6bLqM38nNOBdOsrmclW v+mEQx7H+koQv/ZRMXBxTFmbOz9J88he1z9CZYL+W+0V0PMqmnBSqxiQJDPjtUiSfQsm BT6rdYElmoM/frnoxl7nsFRSdrfrd72PTKGCjkLTOv9DIXnsB19580lL8Vim3QB1jCiV YqSjg7VsQjpC9kR2eU/Mh8yqEQK8HXGIkzbYOREbUXoA4AdCe4+Dxqu8MpF2h1nYkpIU jt7ChK/sg9v0W1Arb9MpUJnhdwLm0RpW2pewN2sZUI8whN68NtoBIxpmBhpbnZ6f2kwY uo3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="xkKypk/5"; 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 76si771469pfs.104.2019.02.13.16.22.59; Wed, 13 Feb 2019 16:23:15 -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="xkKypk/5"; 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 S2390937AbfBMStz (ORCPT + 99 others); Wed, 13 Feb 2019 13:49:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:43410 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394005AbfBMSos (ORCPT ); Wed, 13 Feb 2019 13:44:48 -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 3E2D020835; Wed, 13 Feb 2019 18:44:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550083487; bh=kUDasf+8E8U2iRTbZCJUxcyuojOQrWp8Zd1R4mKGCXI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xkKypk/5vnHq5R+SgKxqhoLNVUvh+maXFFNxGrdVdw8SdqLJBtzueUuESbggfAKqX nuzZj/uxHfYNGmklaQY8exDIYft04n14SKr8jnKo7OC9Hdz7EFx03StqNmIT45KV55 N3F8oX6lOFANLTriMni+gPDtwhXRgoD6aAgSBEo8= 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.20 01/50] mtd: Make sure mtd->erasesize is valid even if the partition is of size 0 Date: Wed, 13 Feb 2019 19:38:06 +0100 Message-Id: <20190213183655.851004077@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190213183655.747168774@linuxfoundation.org> References: <20190213183655.747168774@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.20-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;