Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 520516d1 authored by Joakim Tjernlund's avatar Joakim Tjernlund Committed by Greg Kroah-Hartman
Browse files

mtd: cfi_cmdset_0002: Fix unlocking requests crossing a chip boudary



commit 0cd8116f172eed018907303dbff5c112690eeb91 upstream.

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>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent e592114a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2667,7 +2667,7 @@ static int __maybe_unused cfi_ppb_unlock(struct mtd_info *mtd, loff_t ofs,
		 * sectors shall be unlocked, so lets keep their 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].adr = adr;
			sect[sectors].locked = do_ppb_xxlock(