Skip to contentSkip to conversation

mtd: Make sure mtd->erasesize is valid even if the partition is of size 0

PATCH Applied Boris Brezillon 3 participants 3 messages Jan 30, 2019 – Feb 6, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: Make sure mtd->erasesize is valid even if the partition is of size 0

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")
Cc Geert Uytterhoeven <[email protected]>
---
 drivers/mtd/mtdpart.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/mtd/mtdpart.c +4 -0
index e6d9467f6be0..37f174ccbcec 100644
@@ -480,6 +480,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;
Signature · 1 line
2.17.1
Tested-by on v1 1/1
#1 lore raw

Hi Boris,

Quoted 8 lines · Boris Brezillon

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.

Quoted 5 lines
Fixes 33f45c44d68b ("mtd: Do not allow MTD devices with inconsistent erase properties")
Cc Geert Uytterhoeven <[email protected]>

Thanks, that made the warning disappear.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#2 lore raw
In reply to Boris Brezillon

From: Your Name <[email protected]>

Quoted 8 lines · Boris Brezillon

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.

Quoted 6 lines
Fixes 33f45c44d68b ("mtd: Do not allow MTD devices with inconsistent erase properties")
Cc Geert Uytterhoeven <[email protected]>

Applied to http://git.infradead.org/linux-mtd.git mtd/fixes, thanks.

y'all come back now!