Re: [PATCH] KVM: selftests: Add 'malloc' failure check in config_name

From: Markus Elfring
Date: Tue Apr 23 2024 - 07:12:38 EST



> This patch will add the malloc failure checking


* Please use a corresponding imperative wording for the change description.

* Would you like to add the tag “Fixes” accordingly?



> +++ b/tools/testing/selftests/kvm/get-reg-list.c
> @@ -66,6 +66,7 @@ static const char *config_name(struct vcpu_reg_list *c)
> len += strlen(s->name) + 1;
>
> c->name = malloc(len);
> + TEST_ASSERT(c->name, "-ENOMEM when allocating config name");


Can “errno” be relevant for the error message construction?

Regards,
Markus