[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20211025222244.GB1437674@embeddedor>
Date: Mon, 25 Oct 2021 17:22:44 -0500
From: "Gustavo A. R. Silva" <gustavoars@...nel.org>
To: Len Baker <len.baker@....com>
Cc: Fei Li <fei1.li@...el.com>, Kees Cook <keescook@...omium.org>,
linux-hardening@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2][next] virt: acrn: Prefer array_size and struct_size
over open coded arithmetic
On Sat, Oct 23, 2021 at 12:15:54PM +0200, Len Baker wrote:
[..]
> diff --git a/drivers/virt/acrn/mm.c b/drivers/virt/acrn/mm.c
> index c4f2e15c8a2b..a881742cd48d 100644
> --- a/drivers/virt/acrn/mm.c
> +++ b/drivers/virt/acrn/mm.c
> @@ -168,7 +168,7 @@ int acrn_vm_ram_map(struct acrn_vm *vm, struct acrn_vm_memmap *memmap)
>
> /* Get the page number of the map region */
> nr_pages = memmap->len >> PAGE_SHIFT;
> - pages = vzalloc(nr_pages * sizeof(struct page *));
> + pages = vzalloc(array_size(nr_pages, sizeof(struct page *)));
This form is better:
array_size(nr_pages, sizeof(*pages))
Thanks
--
Gustavo
Powered by blists - more mailing lists