Home Home > GIT Browse > stable
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2019-02-15 10:23:48 +0100
committerJiri Slaby <jslaby@suse.cz>2019-02-15 10:23:51 +0100
commit6a609f5f394356abba6ce920c53a46fac8bb93cc (patch)
tree2df0b5e36e6a9c7ed22f79010e7138fdc7ffecd5
parentb9430b113412c6cee2516daf37178d66b087bbd4 (diff)
mtd: Make sure mtd->erasesize is valid even if the partition
is of size 0 (bnc#1012628).
-rw-r--r--patches.kernel.org/4.20.9-001-mtd-Make-sure-mtd-erasesize-is-valid-even-if-t.patch48
-rw-r--r--series.conf1
2 files changed, 49 insertions, 0 deletions
diff --git a/patches.kernel.org/4.20.9-001-mtd-Make-sure-mtd-erasesize-is-valid-even-if-t.patch b/patches.kernel.org/4.20.9-001-mtd-Make-sure-mtd-erasesize-is-valid-even-if-t.patch
new file mode 100644
index 0000000000..a3021ab419
--- /dev/null
+++ b/patches.kernel.org/4.20.9-001-mtd-Make-sure-mtd-erasesize-is-valid-even-if-t.patch
@@ -0,0 +1,48 @@
+From: Boris Brezillon <bbrezillon@kernel.org>
+Date: Wed, 30 Jan 2019 12:55:52 +0100
+Subject: [PATCH] mtd: Make sure mtd->erasesize is valid even if the partition
+ is of size 0
+References: bnc#1012628
+Patch-mainline: 4.20.9
+Git-commit: ad4635153034c20c6f6e211e2ed3fd38b658649a
+
+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 <geert@linux-m68k.org>
+Cc: <stable@vger.kernel.org>
+Cc: Geert Uytterhoeven <geert@linux-m68k.org>
+Signed-off-by: Boris Brezillon <bbrezillon@kernel.org>
+Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Jiri Slaby <jslaby@suse.cz>
+---
+ drivers/mtd/mtdpart.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
+index 99c460facd5e..0bbb23b014f1 100644
+--- a/drivers/mtd/mtdpart.c
++++ b/drivers/mtd/mtdpart.c
+@@ -470,6 +470,10 @@ static struct mtd_part *allocate_partition(struct mtd_info *parent,
+ /* 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;
+--
+2.20.1
+
diff --git a/series.conf b/series.conf
index 35e2e0ce8b..cdb2177655 100644
--- a/series.conf
+++ b/series.conf
@@ -1083,6 +1083,7 @@
patches.kernel.org/4.20.8-344-ath9k-dynack-make-ewma-estimation-faster.patch
patches.kernel.org/4.20.8-345-ath9k-dynack-check-da-enabled-first-in-samplin.patch
patches.kernel.org/4.20.8-346-Linux-4.20.8.patch
+ patches.kernel.org/4.20.9-001-mtd-Make-sure-mtd-erasesize-is-valid-even-if-t.patch
########################################################
# Build fixes that apply to the vanilla kernel too.