Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Muhammad Usama Anjum <usama.anjum@collabora.com>
To: Kunwu Chan <chentao@kylinos.cn>,
	seanjc@google.com, kunwu.chan@hotmail.com, pbonzini@redhat.com,
	shuah@kernel.org
Cc: Muhammad Usama Anjum <usama.anjum@collabora.com>,
	kvm@vger.kernel.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KVM: selftests: Add 'malloc' failure check in test_vmx_nested_state
Date: Tue, 23 Apr 2024 13:49:48 +0500	[thread overview]
Message-ID: <440693ad-519e-4956-9ace-701bc1c3593e@collabora.com> (raw)
In-Reply-To: <20240423073952.2001989-1-chentao@kylinos.cn>

On 4/23/24 12:39 PM, Kunwu Chan wrote:
> There is a 'malloc' call in test_vmx_nested_state function, which can
> be unsuccessful. This patch will add the malloc failure checking
> to avoid possible null dereference and give more information
> about test fail reasons.
LGTM

Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>

> 
> Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
> ---
>  tools/testing/selftests/kvm/x86_64/vmx_set_nested_state_test.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tools/testing/selftests/kvm/x86_64/vmx_set_nested_state_test.c b/tools/testing/selftests/kvm/x86_64/vmx_set_nested_state_test.c
> index 67a62a5a8895..18afc2000a74 100644
> --- a/tools/testing/selftests/kvm/x86_64/vmx_set_nested_state_test.c
> +++ b/tools/testing/selftests/kvm/x86_64/vmx_set_nested_state_test.c
> @@ -91,6 +91,7 @@ void test_vmx_nested_state(struct kvm_vcpu *vcpu)
>  	const int state_sz = sizeof(struct kvm_nested_state) + getpagesize();
>  	struct kvm_nested_state *state =
>  		(struct kvm_nested_state *)malloc(state_sz);
> +	TEST_ASSERT(state, "-ENOMEM when allocating kvm state");
>  
>  	/* The format must be set to 0. 0 for VMX, 1 for SVM. */
>  	set_default_vmx_state(state, state_sz);

-- 
BR,
Muhammad Usama Anjum

  reply	other threads:[~2024-04-23  8:49 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-23  7:39 [PATCH] KVM: selftests: Add 'malloc' failure check in test_vmx_nested_state Kunwu Chan
2024-04-23  8:49 ` Muhammad Usama Anjum [this message]
2024-04-23 10:45 ` Markus Elfring
2024-04-23 14:56   ` Sean Christopherson
2024-04-23 15:14     ` Andrew Jones
2024-04-23 19:15       ` Sean Christopherson
2024-04-24  2:59         ` Kunwu Chan
2024-04-24  5:41         ` Dan Carpenter
2024-04-24 14:47           ` Sean Christopherson
2024-04-24  7:50         ` Andrew Jones
2024-04-24 14:51           ` Sean Christopherson
2024-04-24 17:18             ` Oliver Upton
2024-04-25 16:25               ` Sean Christopherson
2024-05-10  8:40                 ` Kunwu Chan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=440693ad-519e-4956-9ace-701bc1c3593e@collabora.com \
    --to=usama.anjum@collabora.com \
    --cc=chentao@kylinos.cn \
    --cc=kunwu.chan@hotmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox