lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 20 Jan 2017 19:24:59 +0100
From:   SF Markus Elfring <elfring@...rs.sourceforge.net>
To:     kvm@...r.kernel.org, kvm-ppc@...r.kernel.org,
        linuxppc-dev@...ts.ozlabs.org, Alexander Graf <agraf@...e.com>,
        Benjamin Herrenschmidt <benh@...nel.crashing.org>,
        Michael Ellerman <mpe@...erman.id.au>,
        Paolo Bonzini <pbonzini@...hat.com>,
        Radim Krčmář <rkrcmar@...hat.com>
Cc:     LKML <linux-kernel@...r.kernel.org>,
        kernel-janitors@...r.kernel.org
Subject: [PATCH 06/11] KVM: PPC: Book3S HV: Use kcalloc() in
 kvmppc_alloc_host_rm_ops()

From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Fri, 20 Jan 2017 16:20:43 +0100

* 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.

* Delete the local variable "size" which became unnecessary
  with this refactoring.

* Replace the specification of a data structure 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@...rs.sourceforge.net>
---
 arch/powerpc/kvm/book3s_hv.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index 3122998f6a32..596201b3f22e 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -3199,7 +3199,6 @@ void kvmppc_alloc_host_rm_ops(void)
 	struct kvmppc_host_rm_ops *ops;
 	unsigned long l_ops;
 	int cpu, core;
-	int size;
 
 	/* Not the first time here ? */
 	if (kvmppc_host_rm_ops_hv)
@@ -3209,9 +3208,9 @@ void kvmppc_alloc_host_rm_ops(void)
 	if (!ops)
 		return;
 
-	size = cpu_nr_cores() * sizeof(struct kvmppc_host_rm_core);
-	ops->rm_core = kzalloc(size, GFP_KERNEL);
-
+	ops->rm_core = kcalloc(cpu_nr_cores(),
+			       sizeof(*ops->rm_core),
+			       GFP_KERNEL);
 	if (!ops->rm_core) {
 		kfree(ops);
 		return;
-- 
2.11.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ