]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
mtd: spi-nor: Skip erase logic when SPI_NOR_NO_ERASE is set
authorTudor Ambarus <tudor.ambarus@microchip.com>
Mon, 28 Feb 2022 16:33:34 +0000 (18:33 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 8 Apr 2022 11:57:18 +0000 (13:57 +0200)
commitd5edb2d9b4cecdcbfa5a298054c9f6768b83ba1e
treeb9468eba578dc456c48f39fe5d088a56ce332d9d
parentdf1020681130ad91bab302cb02dcc2439f97600c
mtd: spi-nor: Skip erase logic when SPI_NOR_NO_ERASE is set

commit 151c6b49d679872d6fc0b50e0ad96303091694a2 upstream.

Even if SPI_NOR_NO_ERASE was set, one could still send erase opcodes
to the flash. It is not recommended to send unsupported opcodes to
flashes. Fix the logic and do not set mtd->_erase when SPI_NOR_NO_ERASE
is specified. With this users will not be able to issue erase opcodes to
flashes and instead they will recive an -ENOTSUPP error.

Fixes: b199489d37b2 ("mtd: spi-nor: add the framework for SPI NOR")
Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Reviewed-by: Michael Walle <michael@walle.cc>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20220228163334.277730-1-tudor.ambarus@microchip.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/mtd/spi-nor/core.c