All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: AKASHI Takahiro <takahiro.akashi@linaro.org>,
	Baoquan He <bhe@redhat.com>,
	Stephen Rothwell <sfr@canb.auug.org.au>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] resource: Use 2-factor allocator calls
Date: Wed, 4 Jul 2018 10:31:53 -0700	[thread overview]
Message-ID: <20180704173153.GA34386@beast> (raw)

As already done treewide, switch from open-coded multiplication to using
2-factor allocation helpers.

Signed-off-by: Kees Cook <keescook@chromium.org>
---
 kernel/resource.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/resource.c b/kernel/resource.c
index d717acd12bf4..16debbf2d24c 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -453,7 +453,7 @@ int walk_system_ram_res_rev(u64 start, u64 end, void *arg,
 	int ret = -1;
 
 	/* create a list */
-	rams = vmalloc(sizeof(struct resource) * rams_size);
+	rams = vmalloc(array_size(rams_size, sizeof(struct resource)));
 	if (!rams)
 		return ret;
 
@@ -469,8 +469,8 @@ int walk_system_ram_res_rev(u64 start, u64 end, void *arg,
 			int rams_new_size;
 
 			rams_new_size = rams_size + 16;
-			rams_new = vmalloc(sizeof(struct resource)
-							* rams_new_size);
+			rams_new = vmalloc(array_size(rams_new_size,
+						      sizeof(struct resource)));
 			if (!rams_new)
 				goto out;
 
-- 
2.17.1


-- 
Kees Cook
Pixel Security

             reply	other threads:[~2018-07-04 17:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-04 17:31 Kees Cook [this message]
2018-07-05 22:07 ` [PATCH] resource: Use 2-factor allocator calls Andrew Morton
2018-07-06  1:14   ` Baoquan He

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=20180704173153.GA34386@beast \
    --to=keescook@chromium.org \
    --cc=akpm@linux-foundation.org \
    --cc=bhe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sfr@canb.auug.org.au \
    --cc=takahiro.akashi@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.