From: Heiko Carstens <heiko.carstens@de.ibm.com>
To: SF Markus Elfring <elfring@users.sourceforge.net>
Cc: linux-s390@vger.kernel.org,
Martin Schwidefsky <schwidefsky@de.ibm.com>,
Michael Holzheu <holzheu@linux.vnet.ibm.com>,
LKML <linux-kernel@vger.kernel.org>,
kernel-janitors@vger.kernel.org,
Julia Lawall <julia.lawall@lip6.fr>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH] s390/hypfs: Use kmalloc_array() in diag0c_store()
Date: Thu, 1 Sep 2016 12:32:45 +0200 [thread overview]
Message-ID: <20160901103245.GA3624@osiris> (raw)
In-Reply-To: <5fd5f9ef-923f-4655-54f0-874114dc9428@users.sourceforge.net>
On Thu, Sep 01, 2016 at 11:38:15AM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 1 Sep 2016 11:30:58 +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 "kmalloc_array".
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> arch/s390/hypfs/hypfs_diag0c.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/arch/s390/hypfs/hypfs_diag0c.c b/arch/s390/hypfs/hypfs_diag0c.c
> index 0f1927c..61418a8 100644
> --- a/arch/s390/hypfs/hypfs_diag0c.c
> +++ b/arch/s390/hypfs/hypfs_diag0c.c
> @@ -48,7 +48,9 @@ static void *diag0c_store(unsigned int *count)
>
> get_online_cpus();
> cpu_count = num_online_cpus();
> - cpu_vec = kmalloc(sizeof(*cpu_vec) * num_possible_cpus(), GFP_KERNEL);
> + cpu_vec = kmalloc_array(num_possible_cpus(),
> + sizeof(*cpu_vec),
> + GFP_KERNEL);
How does this improve the situation? For any real life scenario this can't
overflow, but it does add an extra (pointless) runtime check, since
num_possible_cpus() is not a compile time constant.
So, why is this an "issue"?
next prev parent reply other threads:[~2016-09-01 10:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-01 9:38 [PATCH] s390/hypfs: Use kmalloc_array() in diag0c_store() SF Markus Elfring
2016-09-01 10:32 ` Heiko Carstens [this message]
2016-09-01 15:39 ` Paolo Bonzini
2016-09-01 16:53 ` Michael Holzheu
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=20160901103245.GA3624@osiris \
--to=heiko.carstens@de.ibm.com \
--cc=elfring@users.sourceforge.net \
--cc=holzheu@linux.vnet.ibm.com \
--cc=julia.lawall@lip6.fr \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=schwidefsky@de.ibm.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