mtd: Make sure mtd->erasesize is valid even if the partition is of size 0
Subsystems (2)
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.
--- drivers/mtd/mtdpart.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/mtd/mtdpart.c +4 -0
@@ -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
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 theMTD_NO_ERASEflag. 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")Reported-by Geert Uytterhoeven <[email protected]>Cc <[email protected]>Cc Geert Uytterhoeven <[email protected]>Signed-off-by Boris Brezillon <[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
Boris Brezillon
AppliedFrom: 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 theMTD_NO_ERASEflag. 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")Reported-by Geert Uytterhoeven <[email protected]>Cc <[email protected]>Cc Geert Uytterhoeven <[email protected]>Signed-off-by Boris Brezillon <[email protected]>Tested-by Geert Uytterhoeven <[email protected]>
Applied to http://git.infradead.org/linux-mtd.git mtd/fixes, thanks.
y'all come back now!