target init sanity check
authorMathias K <kesmtp@freenet.de>
Tue, 29 Nov 2011 08:37:44 +0000 (09:37 +0100)
committerØyvind Harboe <oyvindharboe@gmail.com>
Tue, 29 Nov 2011 14:35:24 +0000 (14:35 +0000)
Add a test if the pointer to the target_init function in the target struct
is set before the function pointer is used.

Change-Id: Ie4ea542f64f35efce8c5bce2ced9b881bf283ec1
Signed-off-by: Mathias K <kesmtp@freenet.de>
Reviewed-on: http://openocd.zylin.com/241
Tested-by: jenkins
Reviewed-by: Øyvind Harboe <oyvindharboe@gmail.com>
src/target/target.c

index bcd00a1fbe9959224c624ab24c614cf110803383..a414a6a7d7ef2f8542cd4bdf0ea3b5d734b1beb4 100644 (file)
@@ -940,6 +940,8 @@ static int target_init_one(struct command_context *cmd_ctx,
        if (type->check_reset== NULL)
                type->check_reset = default_check_reset;
 
+       assert(type->init_target != NULL);
+
        int retval = type->init_target(cmd_ctx, target);
        if (ERROR_OK != retval)
        {