From: Paolo Bonzini <pbonzini@redhat.com>
To: SF Markus Elfring <elfring@users.sourceforge.net>,
linux-edac@vger.kernel.org, x86@kernel.org,
Borislav Petkov <bp@alien8.de>, "H. Peter Anvin" <hpa@zytor.com>,
Ingo Molnar <mingo@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>,
Tony Luck <tony.luck@intel.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
kernel-janitors@vger.kernel.org,
Julia Lawall <julia.lawall@lip6.fr>
Subject: Re: [PATCH] x86/mce: Use kmalloc_array() in mce_chrdev_read()
Date: Thu, 25 Aug 2016 13:33:36 +0200 [thread overview]
Message-ID: <865fa33f-2339-cafe-d3cc-ccf119c9a50d@redhat.com> (raw)
In-Reply-To: <88a63817-f601-28ce-ed2f-ffeb28512528@users.sourceforge.net>
On 25/08/2016 11:17, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 25 Aug 2016 11:00:05 +0200
>
> * A multiplication for the size determination of a memory allocation
> indicated that an array data structure should be processed.
> Thus reuse the corresponding function "kmalloc_array".
>
> 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>
> ---
> arch/x86/kernel/cpu/mcheck/mce.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
> index 79d8ec8..0bc831d 100644
> --- a/arch/x86/kernel/cpu/mcheck/mce.c
> +++ b/arch/x86/kernel/cpu/mcheck/mce.c
> @@ -1901,7 +1901,7 @@ static ssize_t mce_chrdev_read(struct file *filp, char __user *ubuf,
> unsigned prev, next;
> int i, err;
>
> - cpu_tsc = kmalloc(nr_cpu_ids * sizeof(long), GFP_KERNEL);
> + cpu_tsc = kmalloc_array(nr_cpu_ids, sizeof(*cpu_tsc), GFP_KERNEL);
> if (!cpu_tsc)
> return -ENOMEM;
>
>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
I think you can post the patches with a larger granularity (e.g. one for
all of arch/x86/kernel).
Paolo
WARNING: multiple messages have this Message-ID (diff)
From: Paolo Bonzini <pbonzini@redhat.com>
To: SF Markus Elfring <elfring@users.sourceforge.net>,
linux-edac@vger.kernel.org, x86@kernel.org,
Borislav Petkov <bp@alien8.de>, "H. Peter Anvin" <hpa@zytor.com>,
Ingo Molnar <mingo@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>,
Tony Luck <tony.luck@intel.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
kernel-janitors@vger.kernel.org,
Julia Lawall <julia.lawall@lip6.fr>
Subject: Re: [PATCH] x86/mce: Use kmalloc_array() in mce_chrdev_read()
Date: Thu, 25 Aug 2016 11:33:36 +0000 [thread overview]
Message-ID: <865fa33f-2339-cafe-d3cc-ccf119c9a50d@redhat.com> (raw)
In-Reply-To: <88a63817-f601-28ce-ed2f-ffeb28512528@users.sourceforge.net>
On 25/08/2016 11:17, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 25 Aug 2016 11:00:05 +0200
>
> * A multiplication for the size determination of a memory allocation
> indicated that an array data structure should be processed.
> Thus reuse the corresponding function "kmalloc_array".
>
> 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>
> ---
> arch/x86/kernel/cpu/mcheck/mce.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
> index 79d8ec8..0bc831d 100644
> --- a/arch/x86/kernel/cpu/mcheck/mce.c
> +++ b/arch/x86/kernel/cpu/mcheck/mce.c
> @@ -1901,7 +1901,7 @@ static ssize_t mce_chrdev_read(struct file *filp, char __user *ubuf,
> unsigned prev, next;
> int i, err;
>
> - cpu_tsc = kmalloc(nr_cpu_ids * sizeof(long), GFP_KERNEL);
> + cpu_tsc = kmalloc_array(nr_cpu_ids, sizeof(*cpu_tsc), GFP_KERNEL);
> if (!cpu_tsc)
> return -ENOMEM;
>
>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
I think you can post the patches with a larger granularity (e.g. one for
all of arch/x86/kernel).
Paolo
next prev parent reply other threads:[~2016-08-25 11:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-25 9:17 [PATCH] x86/mce: Use kmalloc_array() in mce_chrdev_read() SF Markus Elfring
2016-08-25 9:17 ` SF Markus Elfring
2016-08-25 11:33 ` Paolo Bonzini [this message]
2016-08-25 11:33 ` Paolo Bonzini
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=865fa33f-2339-cafe-d3cc-ccf119c9a50d@redhat.com \
--to=pbonzini@redhat.com \
--cc=bp@alien8.de \
--cc=elfring@users.sourceforge.net \
--cc=hpa@zytor.com \
--cc=julia.lawall@lip6.fr \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.com \
--cc=x86@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 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.