From 439fcb9b4f717f5a583014acb3e75b789564867c Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Fri, 13 Nov 2015 02:46:26 -0800 Subject: 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 Reviewed-by: Fabio Estevam Reviewed-by: Jagan Teki --- include/spi_flash.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/spi_flash.h b/include/spi_flash.h index 0ae0062..f25b3e7 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) -- cgit v1.1