Commit a8c964ea authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'mtd/fixes-for-4.14-rc3' of git://git.infradead.org/linux-mtd

Pull mtd fixes from Boris Brezillon:

 - Fix partition alignment check in mtdcore.c

 - Fix a buffer overflow in the Atmel NAND driver

* tag 'mtd/fixes-for-4.14-rc3' of git://git.infradead.org/linux-mtd:
  mtd: nand: atmel: fix buffer overflow in atmel_pmecc_user
  mtd: Fix partition alignment check on multi-erasesize devices
parents 0b33ce72 36de8074
...@@ -581,6 +581,14 @@ static struct mtd_part *allocate_partition(struct mtd_info *parent, ...@@ -581,6 +581,14 @@ static struct mtd_part *allocate_partition(struct mtd_info *parent,
slave->mtd.erasesize = parent->erasesize; slave->mtd.erasesize = parent->erasesize;
} }
/*
* Slave erasesize might differ from the master one if the master
* exposes several regions with different erasesize. Adjust
* wr_alignment accordingly.
*/
if (!(slave->mtd.flags & MTD_NO_ERASE))
wr_alignment = slave->mtd.erasesize;
tmp = slave->offset; tmp = slave->offset;
remainder = do_div(tmp, wr_alignment); remainder = do_div(tmp, wr_alignment);
if ((slave->mtd.flags & MTD_WRITEABLE) && remainder) { if ((slave->mtd.flags & MTD_WRITEABLE) && remainder) {
......
...@@ -363,7 +363,7 @@ atmel_pmecc_create_user(struct atmel_pmecc *pmecc, ...@@ -363,7 +363,7 @@ atmel_pmecc_create_user(struct atmel_pmecc *pmecc,
size += (req->ecc.strength + 1) * sizeof(u16); size += (req->ecc.strength + 1) * sizeof(u16);
/* Reserve space for mu, dmu and delta. */ /* Reserve space for mu, dmu and delta. */
size = ALIGN(size, sizeof(s32)); size = ALIGN(size, sizeof(s32));
size += (req->ecc.strength + 1) * sizeof(s32); size += (req->ecc.strength + 1) * sizeof(s32) * 3;
user = kzalloc(size, GFP_KERNEL); user = kzalloc(size, GFP_KERNEL);
if (!user) if (!user)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment