From: David Hildenbrand <david@redhat.com>
To: Janosch Frank <frankja@linux.ibm.com>, kvm@vger.kernel.org
Cc: thuth@redhat.com, pbonzini@redhat.com
Subject: Re: [kvm-unit-tests PATCH] alloc: Add more memalign asserts
Date: Mon, 4 Nov 2019 11:01:17 +0100 [thread overview]
Message-ID: <0d34fe5d-4d5e-5b1f-e72f-45879137b58c@redhat.com> (raw)
In-Reply-To: <20191104092055.5679-1-frankja@linux.ibm.com>
On 04.11.19 10:20, Janosch Frank wrote:
> Let's test for size and alignment in memalign to catch invalid input
> data. Also we need to test for NULL after calling the memalign
> function of the registered alloc operations.
>
> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
> ---
>
> Tested only under s390, tests under other architectures are highly
> appreciated.
>
> ---
> lib/alloc.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/lib/alloc.c b/lib/alloc.c
> index ecdbbc4..eba9dd6 100644
> --- a/lib/alloc.c
> +++ b/lib/alloc.c
> @@ -46,6 +46,7 @@ void *memalign(size_t alignment, size_t size)
> uintptr_t blkalign;
> uintptr_t mem;
>
> + assert(size && alignment);
> assert(alloc_ops && alloc_ops->memalign);
> if (alignment <= sizeof(uintptr_t))
> alignment = sizeof(uintptr_t);
> @@ -56,6 +57,8 @@ void *memalign(size_t alignment, size_t size)
> size = ALIGN(size + METADATA_EXTRA, alloc_ops->align_min);
> p = alloc_ops->memalign(blkalign, size);
>
> + assert(p != NULL);
> +
> /* Leave room for metadata before aligning the result. */
> mem = (uintptr_t)p + METADATA_EXTRA;
> mem = ALIGN(mem, alignment);
>
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Thanks,
David / dhildenb
next prev parent reply other threads:[~2019-11-04 10:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-04 9:20 [kvm-unit-tests PATCH] alloc: Add more memalign asserts Janosch Frank
2019-11-04 10:01 ` David Hildenbrand [this message]
2019-11-04 10:07 ` Paolo Bonzini
2019-11-04 10:12 ` Janosch Frank
2019-11-04 10:16 ` Paolo Bonzini
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=0d34fe5d-4d5e-5b1f-e72f-45879137b58c@redhat.com \
--to=david@redhat.com \
--cc=frankja@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=thuth@redhat.com \
/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