mtd: cfi_cmdset_0002: Avoid walking all chips when unlocking.
authorJoakim Tjernlund <joakim.tjernlund@infinera.com>
Wed, 6 Jun 2018 10:13:30 +0000 (12:13 +0200)
committerBoris Brezillon <boris.brezillon@bootlin.com>
Fri, 22 Jun 2018 08:29:16 +0000 (10:29 +0200)
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>
drivers/mtd/chips/cfi_cmdset_0002.c

index 9cfc2645dd9310db9a51e281386532d867a4219a..1b64ac8c5bc86309061a5540d385eb6e2ca866cc 100644 (file)
@@ -2676,6 +2676,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++;