From acebf24cb9a9331be2c79a2157af45ff9c7de786 Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Tue, 17 Apr 2007 10:34:08 +0300 Subject: [PATCH] Fix segfault in case first open succeeds but second open fails. Signed-off-by: Michael S. Tsirkin --- flint.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/flint.cpp b/flint.cpp index 4d26128..ca6b372 100644 --- a/flint.cpp +++ b/flint.cpp @@ -1746,7 +1746,8 @@ bool ParallelFlash::init_gpios() { } void ParallelFlash::close() { - + if (!_mf) + return; // Restore origin values mwrite4(_mf, GPIO_DIR_L, _dir); mwrite4(_mf, GPIO_POL_L, _pol); @@ -2728,6 +2729,8 @@ bool SpiFlash::init_gpios() { } void SpiFlash::close() { + if (!_mf) + return; // Chip reset does not reset the chip sellect - Make sure after reset // boot loads FW from SPI 0. set_bank(0); -- 2.41.0