diff options
author | Jerome Forissier <jerome.forissier@linaro.org> | 2019-01-18 17:42:56 +0100 |
---|---|---|
committer | Jérôme Forissier <jerome.forissier@linaro.org> | 2019-01-21 09:29:31 +0100 |
commit | 5ee85d76897c95c21fa5eb86d66b288b9b19c62b (patch) | |
tree | 752d474dfe5c885f073148e220259aaadff24b69 | |
parent | b6bc49caed24fe2705767a8783d449b74714586b (diff) |
lockdep: fix dup_call_stack()
dup_call_stack() does not properly deal with the sentinel. Fix it.
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
-rw-r--r-- | core/kernel/lockdep.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/core/kernel/lockdep.c b/core/kernel/lockdep.c index 7d8b89d3..04cb0048 100644 --- a/core/kernel/lockdep.c +++ b/core/kernel/lockdep.c @@ -43,19 +43,21 @@ static struct lockdep_node *lockdep_add_to_graph( static vaddr_t *dup_call_stack(vaddr_t *stack) { + vaddr_t *nstack = NULL; + int n = 0; + if (!stack) return NULL; - int n = 0; - while (stack[n]) n++; - vaddr_t *nstack = malloc(n * sizeof(vaddr_t)); - + nstack = malloc((n + 1) * sizeof(vaddr_t)); if (!nstack) return NULL; - memcpy(nstack, stack, n * sizeof(vaddr_t)); + + memcpy(nstack, stack, (n + 1) * sizeof(vaddr_t)); + return nstack; } |