From: Michal Hocko <mhocko@kernel.org>
To: SF Markus Elfring <elfring@users.sourceforge.net>
Cc: Andrew Morton <akpm@linux-foundation.org>,
George Zhang <georgezhang@vmware.com>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
Masahiro Yamada <yamada.masahiro@socionext.com>,
LKML <linux-kernel@vger.kernel.org>,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] VMCI: Use kmalloc_array() in qp_alloc_ppn_set()
Date: Mon, 09 Jan 2017 09:40:06 +0000 [thread overview]
Message-ID: <20170109094006.GD7495@dhcp22.suse.cz> (raw)
In-Reply-To: <9a04914a-138b-3f5d-b82a-8043b2602bd9@users.sourceforge.net>
On Sun 08-01-17 17:37:08, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 8 Jan 2017 14:04:10 +0100
>
> Multiplications for the size determination of memory allocations
> indicated that array data structures should be processed.
> Thus use the corresponding function "kmalloc_array".
>
> This issue was detected by using the Coccinelle software.
I am surprised that Coccinelle found a single instance of this pattern.
If there are more then I would suggest changing all of them at once
along with the coccinelle program which has been used.
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/misc/vmw_vmci/vmci_queue_pair.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/misc/vmw_vmci/vmci_queue_pair.c b/drivers/misc/vmw_vmci/vmci_queue_pair.c
> index 498c0854305f..7b5c8a89cc54 100644
> --- a/drivers/misc/vmw_vmci/vmci_queue_pair.c
> +++ b/drivers/misc/vmw_vmci/vmci_queue_pair.c
> @@ -486,13 +486,15 @@ static int qp_alloc_ppn_set(void *prod_q,
> if (ppn_set->initialized)
> return VMCI_ERROR_ALREADY_EXISTS;
>
> - produce_ppns > - kmalloc(num_produce_pages * sizeof(*produce_ppns), GFP_KERNEL);
> + produce_ppns = kmalloc_array(num_produce_pages,
> + sizeof(*produce_ppns),
> + GFP_KERNEL);
> if (!produce_ppns)
> return VMCI_ERROR_NO_MEM;
>
> - consume_ppns > - kmalloc(num_consume_pages * sizeof(*consume_ppns), GFP_KERNEL);
> + consume_ppns = kmalloc_array(num_consume_pages,
> + sizeof(*consume_ppns),
> + GFP_KERNEL);
> if (!consume_ppns) {
> kfree(produce_ppns);
> return VMCI_ERROR_NO_MEM;
> --
> 2.11.0
>
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2017-01-09 9:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-08 16:37 [PATCH] VMCI: Use kmalloc_array() in qp_alloc_ppn_set() SF Markus Elfring
2017-01-09 9:40 ` Michal Hocko [this message]
2017-01-09 11:48 ` 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=20170109094006.GD7495@dhcp22.suse.cz \
--to=mhocko@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=elfring@users.sourceforge.net \
--cc=georgezhang@vmware.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=yamada.masahiro@socionext.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