linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Gustavo A. R. Silva" <gustavoars@kernel.org>
To: Len Baker <len.baker@gmx.com>
Cc: Fei Li <fei1.li@intel.com>, Kees Cook <keescook@chromium.org>,
	linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2][next] virt: acrn: Prefer array_size and struct_size over open coded arithmetic
Date: Mon, 25 Oct 2021 17:22:44 -0500	[thread overview]
Message-ID: <20211025222244.GB1437674@embeddedor> (raw)
In-Reply-To: <20211023101554.4064-1-len.baker@gmx.com>

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

      reply	other threads:[~2021-10-25 22:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-23 10:15 [PATCH v2][next] virt: acrn: Prefer array_size and struct_size over open coded arithmetic Len Baker
2021-10-25 22:22 ` Gustavo A. R. Silva [this message]

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=20211025222244.GB1437674@embeddedor \
    --to=gustavoars@kernel.org \
    --cc=fei1.li@intel.com \
    --cc=keescook@chromium.org \
    --cc=len.baker@gmx.com \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.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;
as well as URLs for NNTP newsgroup(s).