[U-Boot,v3,2/7] cmd: sf: fix map_physmem check

Message ID 20180314020307.23475-3-liambeguin@gmail.com
State Superseded
Delegated to: Tom Rini
Headers show
Series
  • [U-Boot,v3,1/7] spi: spi_flash: do not fail silently on bad user input
Related show

Commit Message

Liam Beguin March 14, 2018, 2:03 a.m.
Make sure 0x00 is a valid address to read to. If `addr` is 0x00 then
map_physmem() will return 0 which should be a valid address.

Signed-off-by: Liam Beguin <liambeguin@gmail.com>
---
 cmd/sf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch

diff --git a/cmd/sf.c b/cmd/sf.c
index f971eec781cc..e7ff9a646208 100644
--- a/cmd/sf.c
+++ b/cmd/sf.c
@@ -287,7 +287,7 @@  static int do_spi_flash_read_write(int argc, char * const argv[])
 	}
 
 	buf = map_physmem(addr, len, MAP_WRBACK);
-	if (!buf) {
+	if (!buf && addr) {
 		puts("Failed to map physical memory\n");
 		return 1;
 	}