Commit 0cd8116f authored by Joakim Tjernlund's avatar Joakim Tjernlund Committed by Boris Brezillon

mtd: cfi_cmdset_0002: Fix unlocking requests crossing a chip boudary

The "sector is in requested range" test used to determine whether
sectors should be re-locked or not is done on a variable that is reset
everytime we cross a chip boundary, which can lead to some blocks being
re-locked while the caller expect them to be unlocked.
Fix the check to make sure this cannot happen.

Fixes: 1648eaaa ("mtd: cfi_cmdset_0002: Support Persistent Protection Bits (PPB) locking")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarJoakim Tjernlund <joakim.tjernlund@infinera.com>
Signed-off-by: default avatarBoris Brezillon <boris.brezillon@bootlin.com>
parent 5fdfc3db
...@@ -2660,7 +2660,7 @@ static int __maybe_unused cfi_ppb_unlock(struct mtd_info *mtd, loff_t ofs, ...@@ -2660,7 +2660,7 @@ static int __maybe_unused cfi_ppb_unlock(struct mtd_info *mtd, loff_t ofs,
* sectors shall be unlocked, so lets keep their locking * sectors shall be unlocked, so lets keep their locking
* status at "unlocked" (locked=0) for the final re-locking. * status at "unlocked" (locked=0) for the final re-locking.
*/ */
if ((adr < ofs) || (adr >= (ofs + len))) { if ((offset < ofs) || (offset >= (ofs + len))) {
sect[sectors].chip = &cfi->chips[chipnum]; sect[sectors].chip = &cfi->chips[chipnum];
sect[sectors].adr = adr; sect[sectors].adr = adr;
sect[sectors].locked = do_ppb_xxlock( sect[sectors].locked = do_ppb_xxlock(
......
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