]> git.hungrycats.org Git - linux/commit
mtd: spi-nor: fix wrong "fully unlocked" test
authorBrian Norris <computersforpeace@gmail.com>
Fri, 24 Jun 2016 17:38:14 +0000 (10:38 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 30 Sep 2016 08:12:45 +0000 (10:12 +0200)
commit16964b31c088636d1b0f4de69b8214d27134d5f2
tree781fe5191e2defa55315472194307b4a73e3e026
parentdc4773f971f08d6a674011314d85ff347bd40056
mtd: spi-nor: fix wrong "fully unlocked" test

commit 06586204714b7befec99e554c71687b0b40f351c upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/mtd/spi-nor/spi-nor.c