* [PATCH] mtd: spi-nor: fix wrong "fully unlocked" test
@ 2016-06-24 17:38 Brian Norris
2016-07-10 2:30 ` Brian Norris
0 siblings, 1 reply; 2+ messages in thread
From: Brian Norris @ 2016-06-24 17:38 UTC (permalink / raw)
To: linux-mtd; +Cc: Brian Norris, Giorgio, Ezequiel Garcia
In stm_unlock(), the test to determine whether we've fully unlocked the
flash checks for the lock length to be equal to the flash size. That is
a typo/think-o -- the condition actually means the flash is completely
*locked.* We should be using the inverse condition -- that the lock
length is 0 (i.e., no protection).
The result of this bug is that we never actually turn off the Status
Register Write Disable bit, even if the flash is completely unlocked.
Now we can.
Fixes: 47b8edbf0d43 ("mtd: spi-nor: disallow further writes to SR if WP# is low")
Reported-by: Giorgio <giorgio.nicole@arcor.de>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Cc: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
---
drivers/mtd/spi-nor/spi-nor.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index a63922ed6385..14cf6ac8c0a5 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -661,7 +661,7 @@ static int stm_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len)
status_new = (status_old & ~mask & ~SR_TB) | val;
/* Don't protect status register if we're fully unlocked */
- if (lock_len == mtd->size)
+ if (lock_len == 0)
status_new &= ~SR_SRWD;
if (!use_top)
--
2.8.0.rc3.226.g39d4020
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] mtd: spi-nor: fix wrong "fully unlocked" test
2016-06-24 17:38 [PATCH] mtd: spi-nor: fix wrong "fully unlocked" test Brian Norris
@ 2016-07-10 2:30 ` Brian Norris
0 siblings, 0 replies; 2+ messages in thread
From: Brian Norris @ 2016-07-10 2:30 UTC (permalink / raw)
To: linux-mtd; +Cc: Giorgio, Ezequiel Garcia
On Fri, Jun 24, 2016 at 10:38:14AM -0700, Brian Norris wrote:
> In stm_unlock(), the test to determine whether we've fully unlocked the
> flash checks for the lock length to be equal to the flash size. That is
> a typo/think-o -- the condition actually means the flash is completely
> *locked.* We should be using the inverse condition -- that the lock
> length is 0 (i.e., no protection).
>
> The result of this bug is that we never actually turn off the Status
> Register Write Disable bit, even if the flash is completely unlocked.
> Now we can.
>
> Fixes: 47b8edbf0d43 ("mtd: spi-nor: disallow further writes to SR if WP# is low")
> Reported-by: Giorgio <giorgio.nicole@arcor.de>
> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
> Cc: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Applied to l2-mtd.git
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-07-10 2:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-24 17:38 [PATCH] mtd: spi-nor: fix wrong "fully unlocked" test Brian Norris
2016-07-10 2:30 ` Brian Norris
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).