Commit c1508429 authored by Joakim Tjernlund's avatar Joakim Tjernlund Committed by Greg Kroah-Hartman

mtd: cfi_cmdset_0002: Use right chip in do_ppb_xxlock()

commit f93aa8c4 upstream.

do_ppb_xxlock() fails to add chip->start when querying for lock status
(and chip_ready test), which caused false status reports.
Fix that by adding adr += chip->start and adjust call sites
accordingly.

Fixes: 1648eaaa ("mtd: cfi_cmdset_0002: Support Persistent Protection Bits (PPB) locking")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarJoakim Tjernlund <joakim.tjernlund@infinera.com>
Signed-off-by: default avatarBoris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 5069cd50
...@@ -2551,8 +2551,9 @@ static int __maybe_unused do_ppb_xxlock(struct map_info *map, ...@@ -2551,8 +2551,9 @@ static int __maybe_unused do_ppb_xxlock(struct map_info *map,
unsigned long timeo; unsigned long timeo;
int ret; int ret;
adr += chip->start;
mutex_lock(&chip->mutex); mutex_lock(&chip->mutex);
ret = get_chip(map, chip, adr + chip->start, FL_LOCKING); ret = get_chip(map, chip, adr, FL_LOCKING);
if (ret) { if (ret) {
mutex_unlock(&chip->mutex); mutex_unlock(&chip->mutex);
return ret; return ret;
...@@ -2570,8 +2571,8 @@ static int __maybe_unused do_ppb_xxlock(struct map_info *map, ...@@ -2570,8 +2571,8 @@ static int __maybe_unused do_ppb_xxlock(struct map_info *map,
if (thunk == DO_XXLOCK_ONEBLOCK_LOCK) { if (thunk == DO_XXLOCK_ONEBLOCK_LOCK) {
chip->state = FL_LOCKING; chip->state = FL_LOCKING;
map_write(map, CMD(0xA0), chip->start + adr); map_write(map, CMD(0xA0), adr);
map_write(map, CMD(0x00), chip->start + adr); map_write(map, CMD(0x00), adr);
} else if (thunk == DO_XXLOCK_ONEBLOCK_UNLOCK) { } else if (thunk == DO_XXLOCK_ONEBLOCK_UNLOCK) {
/* /*
* Unlocking of one specific sector is not supported, so we * Unlocking of one specific sector is not supported, so we
...@@ -2609,7 +2610,7 @@ static int __maybe_unused do_ppb_xxlock(struct map_info *map, ...@@ -2609,7 +2610,7 @@ static int __maybe_unused do_ppb_xxlock(struct map_info *map,
map_write(map, CMD(0x00), chip->start); map_write(map, CMD(0x00), chip->start);
chip->state = FL_READY; chip->state = FL_READY;
put_chip(map, chip, adr + chip->start); put_chip(map, chip, adr);
mutex_unlock(&chip->mutex); mutex_unlock(&chip->mutex);
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment