From: Andrew Jones Subject: [kvm-unit-tests PATCH] lib/x86/stack: fix null dereference Date: Thu, 3 Nov 2016 10:11:29 +0100 Message-ID: <1478164289-26439-1-git-send-email-drjones@redhat.com> Cc: pbonzini@redhat.com, pfeiner@google.com To: kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:50478 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754226AbcKCJLd (ORCPT ); Thu, 3 Nov 2016 05:11:33 -0400 Sender: kvm-owner@vger.kernel.org List-ID: With gcc 6.2.1 (gcc-6.2.1-2.fc24.x86_64) hitting an assert() in x86 code causes an infinite loop. This is due to a null dereference in backtrace_frame. Let's not do that. Signed-off-by: Andrew Jones --- lib/x86/stack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/x86/stack.c b/lib/x86/stack.c index d75c0beb46fb..5ecd97ce90b9 100644 --- a/lib/x86/stack.c +++ b/lib/x86/stack.c @@ -13,7 +13,7 @@ int backtrace_frame(const void *frame, const void **return_addrs, int max_depth) } walking = 1; - for (depth = 0; depth < max_depth; depth++) { + for (depth = 0; bp && depth < max_depth; depth++) { return_addrs[depth] = (void *) bp[1]; if (return_addrs[depth] == 0) break; -- 2.7.4