From: Paolo Bonzini Subject: Re: [kvm-unit-tests PATCH] lib/x86/stack: fix null dereference Date: Thu, 3 Nov 2016 13:22:39 +0100 Message-ID: <032dbff4-c3d0-b0d0-781b-b907ea7efe13@redhat.com> References: <1478164289-26439-1-git-send-email-drjones@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: pfeiner@google.com To: Andrew Jones , kvm@vger.kernel.org Return-path: Received: from mail-wm0-f65.google.com ([74.125.82.65]:36453 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754285AbcKCMWn (ORCPT ); Thu, 3 Nov 2016 08:22:43 -0400 Received: by mail-wm0-f65.google.com with SMTP id c17so7740481wmc.3 for ; Thu, 03 Nov 2016 05:22:43 -0700 (PDT) In-Reply-To: <1478164289-26439-1-git-send-email-drjones@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 03/11/2016 10:11, Andrew Jones wrote: > 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; > Applied, thanks. Paolo