[U-Boot] [PATCH v2 4/5] fpga: altera: cyclon2: Check function pointer before calling

Alexander Dahl ada at thorsis.com
Fri Jun 28 12:41:23 UTC 2019


As already done for the 'pre' function, a check is added to not follow a
NULL pointer, if somebody has not assigned a 'post' function.

Signed-off-by: Alexander Dahl <ada at thorsis.com>
---
 drivers/fpga/cyclon2.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/fpga/cyclon2.c b/drivers/fpga/cyclon2.c
index ab979b017a..c929cd2cc5 100644
--- a/drivers/fpga/cyclon2.c
+++ b/drivers/fpga/cyclon2.c
@@ -183,8 +183,12 @@ static int CYC2_ps_load(Altera_desc *desc, const void *buf, size_t bsize)
 		else
 			puts("Fail.\n");
 #endif
-		(*fn->post) (cookie);
 
+		/*
+		 * Run the post configuration function if there is one.
+		 */
+		if (*fn->post)
+			(*fn->post) (cookie);
 	} else {
 		printf("%s: NULL Interface function table!\n", __func__);
 	}
-- 
2.11.0



More information about the U-Boot mailing list