summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorBin Meng <bmeng.cn@gmail.com>2015-11-13 02:46:26 -0800
committerTom Rini <trini@konsulko.com>2015-11-13 09:47:22 -0500
commit439fcb9b4f717f5a583014acb3e75b789564867c (patch)
tree896aa273c728253b8a6061c7d6710a7bc4bba13a /include
parent9ac4fc82071ce346e3885118242ff45d22f69b82 (diff)
sf: Fix NULL pointer exception for flashes without lock methods
commit c3c016c "sf: Add SPI NOR protection mechanism" introduced flash_lock()/flash_unlock()/flash_is_locked() methods for SPI flash, but not every flash driver supplies these. We should test these methods against NULL before actually calling them. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Fabio Estevam <fabio.estevam@freescale.com> Reviewed-by: Jagan Teki <jteki@openedev.com>
Diffstat (limited to 'include')
-rw-r--r--include/spi_flash.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/include/spi_flash.h b/include/spi_flash.h
index 0ae0062d12..f25b3e7819 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -237,7 +237,7 @@ static inline int spi_flash_erase(struct spi_flash *flash, u32 offset,
static inline int spi_flash_protect(struct spi_flash *flash, u32 ofs, u32 len,
bool prot)
{
- if (!flash->flash_lock)
+ if (!flash->flash_lock || !flash->flash_unlock)
return -EOPNOTSUPP;
if (prot)