]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.14.53/mtd-cfi_cmdset_0002-use-right-chip-in-do_ppb_xxlock.patch
5.1-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.14.53 / mtd-cfi_cmdset_0002-use-right-chip-in-do_ppb_xxlock.patch
CommitLineData
d1cf1a50
GKH
1From f93aa8c4de307069c270b2d81741961162bead6c Mon Sep 17 00:00:00 2001
2From: Joakim Tjernlund <joakim.tjernlund@infinera.com>
3Date: Wed, 6 Jun 2018 12:13:27 +0200
4Subject: mtd: cfi_cmdset_0002: Use right chip in do_ppb_xxlock()
5
6From: Joakim Tjernlund <joakim.tjernlund@infinera.com>
7
8commit f93aa8c4de307069c270b2d81741961162bead6c upstream.
9
10do_ppb_xxlock() fails to add chip->start when querying for lock status
11(and chip_ready test), which caused false status reports.
12Fix that by adding adr += chip->start and adjust call sites
13accordingly.
14
15Fixes: 1648eaaa1575 ("mtd: cfi_cmdset_0002: Support Persistent Protection Bits (PPB) locking")
16Cc: stable@vger.kernel.org
17Signed-off-by: Joakim Tjernlund <joakim.tjernlund@infinera.com>
18Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
19Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
20
21---
22 drivers/mtd/chips/cfi_cmdset_0002.c | 9 +++++----
23 1 file changed, 5 insertions(+), 4 deletions(-)
24
25--- a/drivers/mtd/chips/cfi_cmdset_0002.c
26+++ b/drivers/mtd/chips/cfi_cmdset_0002.c
30f57f1d 27@@ -2553,8 +2553,9 @@ static int __maybe_unused do_ppb_xxlock(
d1cf1a50
GKH
28 unsigned long timeo;
29 int ret;
30
31+ adr += chip->start;
32 mutex_lock(&chip->mutex);
33- ret = get_chip(map, chip, adr + chip->start, FL_LOCKING);
34+ ret = get_chip(map, chip, adr, FL_LOCKING);
35 if (ret) {
36 mutex_unlock(&chip->mutex);
37 return ret;
30f57f1d 38@@ -2572,8 +2573,8 @@ static int __maybe_unused do_ppb_xxlock(
d1cf1a50
GKH
39
40 if (thunk == DO_XXLOCK_ONEBLOCK_LOCK) {
41 chip->state = FL_LOCKING;
42- map_write(map, CMD(0xA0), chip->start + adr);
43- map_write(map, CMD(0x00), chip->start + adr);
44+ map_write(map, CMD(0xA0), adr);
45+ map_write(map, CMD(0x00), adr);
46 } else if (thunk == DO_XXLOCK_ONEBLOCK_UNLOCK) {
47 /*
48 * Unlocking of one specific sector is not supported, so we
30f57f1d 49@@ -2611,7 +2612,7 @@ static int __maybe_unused do_ppb_xxlock(
d1cf1a50
GKH
50 map_write(map, CMD(0x00), chip->start);
51
52 chip->state = FL_READY;
53- put_chip(map, chip, adr + chip->start);
54+ put_chip(map, chip, adr);
55 mutex_unlock(&chip->mutex);
56
57 return ret;