From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755717AbcIJJ6Q (ORCPT ); Sat, 10 Sep 2016 05:58:16 -0400 Received: from mout.web.de ([217.72.192.78]:65454 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752805AbcIJJ6N (ORCPT ); Sat, 10 Sep 2016 05:58:13 -0400 Subject: [PATCH 16/30] ACPI-processor: Use kmalloc_array() in acpi_processor_get_throttling_states() To: linux-acpi@vger.kernel.org, Len Brown , "Rafael J. Wysocki" References: Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall , Paolo Bonzini From: SF Markus Elfring Message-ID: <09d308b2-b16f-ee86-fb15-7fd11e902018@users.sourceforge.net> Date: Sat, 10 Sep 2016 11:58:04 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:9Qgqz+nAiG/SqBtWZla+CIyuLVTHVO0zUj4xQfnDJ9eL/TGnw25 3EGnjcs7uU2oLOl42C5xRfeBI1eJXaodYLsYNglwLvKPpg0ayoDw3jCVz1si4YtLp8zyDtS YOFRFP53xltlDgtomtNEa70xYl9+hHuegL0lIQOSeN6om1ELRxgrsJ60ONpbOaxA27I8ynq xQ8j7qsjQu4cpdw7jaqZw== X-UI-Out-Filterresults: notjunk:1;V01:K0:AIPBHmztKP8=:1Lem5gZBoUDmND9/AHPj4m PmcTrSDMyJyPtCdkrSjND/PUI5bhxh+jzkjXryvBmQ6oOCpDkaJZxd5Q7Ks72S0+OxpjXgSVC 3bF1zHFCQUBsnk6fPGVfoSOWFb/bZJwQRJlwIo68NSuvNB/sMUBKPaiIlaMBRyDUFWLG+6dGB lPOuO0GIP3t4nMwsI/FZIQ2o3wzImcbIWxoN4C5oBsjx0x/06fa+jd82MUYNq02HRzVi2RY1H nchhG3+pEL4TGm4XLXGl7m2tYu6f8cBbQ37qJM4p/+Brq4BoKnZnxV+8ge3pBTad2K3nq3StR lAE5hhLq+R2bvB8gbABEtsWuViqs+KTqh8EyIfZxj3etTSN0U1++LsNOIvobrtnNte7uKsgZT SGRcN1i7FlwMOr4YNpuWwYfm2z7OHyeWVMW6KTTeZTYXEiG0vqSuM7jaY9A6SFxb0qyYSONy9 xwI9FEGUabSzXXObzs0KNKf+73x43V4iIH2M9gnwsT1/cDLge83xZ+u3229uHW2gJMsOQ8vNf XRyANAtua/84oelvWe8HAH7Cmfq3Wq6KWj+Go7Jx7sW95qFEQCcTDVZnKPft1e16oBu671pOL 1miutQDPhD1e/eYs4GOEQvIVQuPPnr5ssPnlAwVmnVTneiyPbQfvwJcI8ONxpZMj83RH5pHdC q3RX+lQY60s00E/rfgDjbq4RQATZkcZpHP7ulErRVaOwMwf7XRE5nX/Y6MztZcuWEq6bWT/UH AmNeHmunt7YP7pFDX3TvFJE9PIUGA35vdfDN/GfEQDqgQFQu4qFwBhI4VCteaxrREjHCY9JwM r7NkOru Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Elfring Date: Tue, 6 Sep 2016 19:15:02 +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 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 --- drivers/acpi/processor_throttling.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c index c72e648..0a46b7f 100644 --- a/drivers/acpi/processor_throttling.c +++ b/drivers/acpi/processor_throttling.c @@ -533,9 +533,10 @@ static int acpi_processor_get_throttling_states(struct acpi_processor *pr) tss->package.count)); pr->throttling.state_count = tss->package.count; - pr->throttling.states_tss = - kmalloc(sizeof(struct acpi_processor_tx_tss) * tss->package.count, - GFP_KERNEL); + pr->throttling.states_tss = kmalloc_array(tss->package.count, + sizeof(*pr-> + throttling.states_tss), + GFP_KERNEL); if (!pr->throttling.states_tss) { result = -ENOMEM; goto end; -- 2.10.0