From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Date: Wed, 13 Jan 2010 09:37:57 +0000 Subject: Re: + kvm-ia64-dereference-of-null-pointer-in-set_pal_result.patch Message-Id: <4B4D9475.6050906@redhat.com> List-Id: References: <4B4D90DF.7020700@redhat.com> In-Reply-To: <4B4D90DF.7020700@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: kvm-ia64@vger.kernel.org On 01/13/2010 11:32 AM, Andrew Morton wrote: > On Wed, 13 Jan 2010 11:22:39 +0200 Avi Kivity wrote: > > >> On 01/13/2010 12:11 AM, akpm@linux-foundation.org wrote: >> >>> Subject: kvm/ia64: dereference of NULL pointer in set_pal_result() >>> From: Roel Kluin >>> >>> Do not dereference a NULL pointer >>> >>> diff -puN arch/ia64/kvm/kvm_fw.c~kvm-ia64-dereference-of-null-pointer-in-set_pal_result arch/ia64/kvm/kvm_fw.c >>> --- a/arch/ia64/kvm/kvm_fw.c~kvm-ia64-dereference-of-null-pointer-in-set_pal_result >>> +++ a/arch/ia64/kvm/kvm_fw.c >>> @@ -75,9 +75,11 @@ static void set_pal_result(struct kvm_vc >>> struct exit_ctl_data *p; >>> >>> p = kvm_get_exit_data(vcpu); >>> - if (p&& p->exit_reason = EXIT_REASON_PAL_CALL) { >>> + if (!p) >>> + return; >>> + if (p->exit_reason = EXIT_REASON_PAL_CALL) { >>> p->u.pal_data.ret = result; >>> - return ; >>> + return; >>> } >>> INIT_PAL_STATUS_UNIMPLEMENTED(p->u.pal_data.ret); >>> } >>> >>> >> >> kvm_get_exit_data() cannot return a NULL pointer. >> > In that case set_pal_result() doesn't need to test for that. > > Roel looks for code along the lines of > > if (p) > ... > > *p; > I see. I think it's worthwhile to look deeper rather than converting things mechanically. After all, the code may have actually worked before the patch. -- error compiling committee.c: too many arguments to function From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: + kvm-ia64-dereference-of-null-pointer-in-set_pal_result.patch added to -mm tree Date: Wed, 13 Jan 2010 11:37:57 +0200 Message-ID: <4B4D9475.6050906@redhat.com> References: <201001122211.o0CMBSxg030700@imap1.linux-foundation.org> <4B4D90DF.7020700@redhat.com> <20100113013253.5913fc63.akpm@linux-foundation.org> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: KVM list , roel.kluin@gmail.com, mtosatti@redhat.com, tony.luck@intel.com, xiantao.zhang@intel.com, "kvm-ia64@vger.kernel.org" To: Andrew Morton Return-path: Received: from mx1.redhat.com ([209.132.183.28]:63919 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755191Ab0AMJi0 (ORCPT ); Wed, 13 Jan 2010 04:38:26 -0500 In-Reply-To: <20100113013253.5913fc63.akpm@linux-foundation.org> Sender: kvm-owner@vger.kernel.org List-ID: On 01/13/2010 11:32 AM, Andrew Morton wrote: > On Wed, 13 Jan 2010 11:22:39 +0200 Avi Kivity wrote: > > >> On 01/13/2010 12:11 AM, akpm@linux-foundation.org wrote: >> >>> Subject: kvm/ia64: dereference of NULL pointer in set_pal_result() >>> From: Roel Kluin >>> >>> Do not dereference a NULL pointer >>> >>> diff -puN arch/ia64/kvm/kvm_fw.c~kvm-ia64-dereference-of-null-pointer-in-set_pal_result arch/ia64/kvm/kvm_fw.c >>> --- a/arch/ia64/kvm/kvm_fw.c~kvm-ia64-dereference-of-null-pointer-in-set_pal_result >>> +++ a/arch/ia64/kvm/kvm_fw.c >>> @@ -75,9 +75,11 @@ static void set_pal_result(struct kvm_vc >>> struct exit_ctl_data *p; >>> >>> p = kvm_get_exit_data(vcpu); >>> - if (p&& p->exit_reason == EXIT_REASON_PAL_CALL) { >>> + if (!p) >>> + return; >>> + if (p->exit_reason == EXIT_REASON_PAL_CALL) { >>> p->u.pal_data.ret = result; >>> - return ; >>> + return; >>> } >>> INIT_PAL_STATUS_UNIMPLEMENTED(p->u.pal_data.ret); >>> } >>> >>> >> >> kvm_get_exit_data() cannot return a NULL pointer. >> > In that case set_pal_result() doesn't need to test for that. > > Roel looks for code along the lines of > > if (p) > ... > > *p; > I see. I think it's worthwhile to look deeper rather than converting things mechanically. After all, the code may have actually worked before the patch. -- error compiling committee.c: too many arguments to function