From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755958AbcH1RS0 (ORCPT ); Sun, 28 Aug 2016 13:18:26 -0400 Received: from mout.web.de ([212.227.17.12]:56098 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755877AbcH1RSY (ORCPT ); Sun, 28 Aug 2016 13:18:24 -0400 Subject: [PATCH 5/6] KVM: PPC: e500: Use kmalloc_array() in kvmppc_e500_tlb_init() To: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Alexander Graf , Benjamin Herrenschmidt , Michael Ellerman , Paolo Bonzini , Paul Mackerras , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= References: <566ABCD9.1060404@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall From: SF Markus Elfring Message-ID: Date: Sun, 28 Aug 2016 19:18:07 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:SFS3dxqOwXE2Sth0KQ0biWeEK3FOc3EhD/8TXkPntzhuhy+9RZE 7+mLsYg2jaF1FtgkiJR54clM31qCNq+QthkjZrx8RyrkTyLdjOZF1mOAxEVtjJzAUsUlcCl dQBHGjAE1yqKPaGuaEsj/VhdteDJXvwvdpDInPftQG11A97GGjIkBQisxCZrOS8FZy1d1BD 930n1w1x4KCe8rGqSlJBQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:Fk3QcgjWhrM=:6GRJI9gFrG2QS60PkU+6q9 t68XXbq5kv+68d4ONAsLbrvFNF44RXP89XjaP+jqpU8b0eJ3DJx+EgRdoWkoaMw9KnW6q1zL+ l0Xm32FnqnLC+G465Grj0kACFQTBqc6fW31SvIhesdH0UfKf5iEDvfJB63uG9UMy5tZLWTgBd lpgjoEBh+PJeCIdBRWf+4Ei6Qf0V7YdDBfC9jXoJsR1PGWxjK+sivX/99xi5V9wRlYuObxCJf +JpsBeBYPmtXdOTgVTyCxNpEfzA/KSP2zYoGXApnUYKew6hDasBISmGr/91+sNjrPTOQvu+2h aSCVyHncxJf2gib29YS6pmqHMAJSEteNlFTeYNDgsEAatx7EaatzA7towd/mywlwTktzL2MyW tA2BTO2Vzl6Zjo61Me5wne3ro564ZhALii0tU1vcRpaIb2QPko591oXyDY1b5+HDwHuHZ2exw WuXwvBf6UJUgieVzFhU3drJYOWKdtKFeDSrFqPpaUFqKYL3IvoB1V7Is0j0hODFYJpYvgnup1 2liROIJu7RyY+EhCRpVOux/55G34Q9LFHOEzZ0pDpCS+MQPn4egHSLNfu9U8CVISebn1djWT/ hg1QORKN6AnOjwHVQopE9f92sJ/MYVzcS3mPCgn6iskAT6YqlTL/J9F9bqvn2ZmLOQ92vciNr iBrQuk9gZESEAPT5MzstCsoywsn8SfzLYj0STAZqsLU1cL3EmPpWRETKzlcyYxko/VrklvACy /xcNW91LetJT2/8GMyD7RGA0mZHCTwrWJumssz/BVCpos9ATgk4R4Sf/rqpLlslXLMxk5oaIJ If1wGnL Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Elfring Date: Sun, 28 Aug 2016 18:40:08 +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". * 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 --- arch/powerpc/kvm/e500_mmu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/kvm/e500_mmu.c b/arch/powerpc/kvm/e500_mmu.c index 2be2afc4..0a2eeb1 100644 --- a/arch/powerpc/kvm/e500_mmu.c +++ b/arch/powerpc/kvm/e500_mmu.c @@ -905,8 +905,6 @@ static int vcpu_mmu_init(struct kvm_vcpu *vcpu, int kvmppc_e500_tlb_init(struct kvmppc_vcpu_e500 *vcpu_e500) { struct kvm_vcpu *vcpu = &vcpu_e500->vcpu; - int entry_size = sizeof(struct kvm_book3e_206_tlb_entry); - int entries = KVM_E500_TLB0_SIZE + KVM_E500_TLB1_SIZE; if (e500_mmu_host_init(vcpu_e500)) goto err; @@ -921,7 +919,10 @@ int kvmppc_e500_tlb_init(struct kvmppc_vcpu_e500 *vcpu_e500) vcpu_e500->gtlb_params[1].ways = KVM_E500_TLB1_SIZE; vcpu_e500->gtlb_params[1].sets = 1; - vcpu_e500->gtlb_arch = kmalloc(entries * entry_size, GFP_KERNEL); + vcpu_e500->gtlb_arch = kmalloc_array(KVM_E500_TLB0_SIZE + + KVM_E500_TLB1_SIZE, + sizeof(*vcpu_e500->gtlb_arch), + GFP_KERNEL); if (!vcpu_e500->gtlb_arch) return -ENOMEM; -- 2.9.3