]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.14.53/mtd-cfi_cmdset_0002-fix-unlocking-requests-crossing-a-chip-boudary.patch
5.1-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.14.53 / mtd-cfi_cmdset_0002-fix-unlocking-requests-crossing-a-chip-boudary.patch
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
5
6 From: Joakim Tjernlund <joakim.tjernlund@infinera.com>
7
8 commit 0cd8116f172eed018907303dbff5c112690eeb91 upstream.
9
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.
15
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>
21
22 ---
23 drivers/mtd/chips/cfi_cmdset_0002.c | 2 +-
24 1 file changed, 1 insertion(+), 1 deletion(-)
25
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.
31 */
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(