mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: Arnd Bergmann <arnd@arndb.de>, Jan Kara <jack@suse.cz>,
	Jesper Nilsson <jesper.nilsson@axis.com>,
	Kumar Gala <galak@kernel.crashing.org>,
	Lorenzo Stoakes <lstoakes@gmail.com>,
	Michal Hocko <mhocko@suse.com>, Timur Tabi <timur@freescale.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 4/5] fsl_hypervisor: Use kcalloc() in ioctl_memcpy()
Date: Sat, 20 May 2017 21:14:45 +0200	[thread overview]
Message-ID: <20c641bb-33af-39ec-9208-cbc560441223@users.sourceforge.net> (raw)
In-Reply-To: <38a9b933-4cdc-53e7-0a4c-20f96c57648c@users.sourceforge.net>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 20 May 2017 20:15:57 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kcalloc".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data type by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/virt/fsl_hypervisor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/virt/fsl_hypervisor.c b/drivers/virt/fsl_hypervisor.c
index 9e881dc29c6b..4031632b8c9d 100644
--- a/drivers/virt/fsl_hypervisor.c
+++ b/drivers/virt/fsl_hypervisor.c
@@ -223,5 +223,5 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p)
 	 * 'pages' is an array of struct page pointers that's initialized by
 	 * get_user_pages().
 	 */
-	pages = kzalloc(num_pages * sizeof(struct page *), GFP_KERNEL);
+	pages = kcalloc(num_pages, sizeof(*pages), GFP_KERNEL);
 	if (!pages) {
-- 
2.13.0

  parent reply	other threads:[~2017-05-20 19:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-20 19:08 [PATCH 0/5] fsl_hypervisor: Adjustments for two function implementations SF Markus Elfring
2017-05-20 19:10 ` [PATCH 1/5] fsl_hypervisor: Improve a size determination in fsl_hv_open() SF Markus Elfring
2017-05-20 19:12 ` [PATCH 2/5] fsl_hypervisor: Delete an error message for a failed memory allocation " SF Markus Elfring
2017-05-20 19:13 ` [PATCH 3/5] fsl_hypervisor: Return the success indication only as a constant " SF Markus Elfring
2017-05-20 19:14 ` SF Markus Elfring [this message]
2017-05-20 19:16 ` [PATCH 5/5] fsl_hypervisor: Delete error messages for failed memory allocations in ioctl_memcpy() SF Markus Elfring

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=20c641bb-33af-39ec-9208-cbc560441223@users.sourceforge.net \
    --to=elfring@users.sourceforge.net \
    --cc=arnd@arndb.de \
    --cc=galak@kernel.crashing.org \
    --cc=jack@suse.cz \
    --cc=jesper.nilsson@axis.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lstoakes@gmail.com \
    --cc=mhocko@suse.com \
    --cc=timur@freescale.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

Powered by JetHome