1 From 0cd8116f172eed018907303dbff5c112690eeb91 Mon Sep 17 00:00:00 2001
2 From: Joakim Tjernlund <joakim.tjernlund@infinera.com>
3 Date: Wed, 6 Jun 2018 12:13:29 +0200
4 Subject: mtd: cfi_cmdset_0002: Fix unlocking requests crossing a chip boudary
6 From: Joakim Tjernlund <joakim.tjernlund@infinera.com>
8 commit 0cd8116f172eed018907303dbff5c112690eeb91 upstream.
10 The "sector is in requested range" test used to determine whether
11 sectors should be re-locked or not is done on a variable that is reset
12 everytime we cross a chip boundary, which can lead to some blocks being
13 re-locked while the caller expect them to be unlocked.
14 Fix the check to make sure this cannot happen.
16 Fixes: 1648eaaa1575 ("mtd: cfi_cmdset_0002: Support Persistent Protection Bits (PPB) locking")
17 Cc: stable@vger.kernel.org
18 Signed-off-by: Joakim Tjernlund <joakim.tjernlund@infinera.com>
19 Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
20 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
23 drivers/mtd/chips/cfi_cmdset_0002.c | 2 +-
24 1 file changed, 1 insertion(+), 1 deletion(-)
26 --- a/drivers/mtd/chips/cfi_cmdset_0002.c
27 +++ b/drivers/mtd/chips/cfi_cmdset_0002.c
28 @@ -2669,7 +2669,7 @@ static int __maybe_unused cfi_ppb_unlock
29 * sectors shall be unlocked, so lets keep their locking
30 * status at "unlocked" (locked=0) for the final re-locking.
32 - if ((adr < ofs) || (adr >= (ofs + len))) {
33 + if ((offset < ofs) || (offset >= (ofs + len))) {
34 sect[sectors].chip = &cfi->chips[chipnum];
35 sect[sectors].adr = adr;
36 sect[sectors].locked = do_ppb_xxlock(