summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoakim Tjernlund <joakim.tjernlund@infinera.com>2018-06-06 12:13:30 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-07-03 11:26:58 +0200
commita5382451cc5745efa920cbfc5a108f03c57a7a54 (patch)
treefdbfbd60fb00096503d466be70f5c4e07eae18c4
parent6b4d98009539a28c7b14a922caf1bed539ac279c (diff)
downloadlinux-stable-a5382451cc5745efa920cbfc5a108f03c57a7a54.tar.gz
linux-stable-a5382451cc5745efa920cbfc5a108f03c57a7a54.tar.bz2
linux-stable-a5382451cc5745efa920cbfc5a108f03c57a7a54.zip
mtd: cfi_cmdset_0002: Avoid walking all chips when unlocking.
commit f1ce87f6080b1dda7e7b1eda3da332add19d87b9 upstream. cfi_ppb_unlock() walks all flash chips when unlocking sectors, avoid walking chips unaffected by the unlock operation. Fixes: 1648eaaa1575 ("mtd: cfi_cmdset_0002: Support Persistent Protection Bits (PPB) locking") Cc: stable@vger.kernel.org Signed-off-by: Joakim Tjernlund <joakim.tjernlund@infinera.com> Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0002.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c
index a90e173b0711..3a8a88fa06aa 100644
--- a/drivers/mtd/chips/cfi_cmdset_0002.c
+++ b/drivers/mtd/chips/cfi_cmdset_0002.c
@@ -2665,6 +2665,8 @@ static int __maybe_unused cfi_ppb_unlock(struct mtd_info *mtd, loff_t ofs,
i++;
if (adr >> cfi->chipshift) {
+ if (offset >= (ofs + len))
+ break;
adr = 0;
chipnum++;