Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1480570

[PATCH 16/30] ACPI-processor: Use kmalloc_array() in acpi_processor_get_throttling_states()

From SF Markus Elfring <elfring@users.sourceforge.net>
Newsgroups linux.kernel
Subject [PATCH 16/30] ACPI-processor: Use kmalloc_array() in acpi_processor_get_throttling_states()
Date 2016-09-10 12:00 +0200
Message-ID <sfNeN-70F-11@gated-at.bofh.it> (permalink)
References <sfMVr-6Un-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Markus Elfring <elfring@users.sourceforge.net>
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 <elfring@users.sourceforge.net>
---
 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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 00/30] ACPI-processor: Fine-tuning for several function  implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-10 11:40 +0200
  [PATCH 03/30] ACPI-processor: Rename jump labels in  acpi_processor_get_performance_states() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-10 11:50 +0200
  [PATCH 05/30] ACPI-processor: Rename jump labels in  acpi_processor_preregister_performance() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-10 11:50 +0200
  [PATCH 04/30] ACPI-processor: Delete two unnecessary initialisations  in acpi_processor_get_performance_states() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-10 11:50 +0200
  [PATCH 08/30] ACPI-processor: Delete two unnecessary initialisations  in acpi_processor_get_psd() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-10 11:50 +0200
  [PATCH 07/30] ACPI-processor: Rename jump labels in  acpi_processor_get_psd() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-10 11:50 +0200
  [PATCH 06/30] ACPI-processor: Move a success indication in  acpi_processor_preregister_performance() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-10 11:50 +0200
  [PATCH 15/30] ACPI-processor: Delete an unnecessary initialisation in  acpi_processor_get_platform_limit() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-10 12:00 +0200
  [PATCH 17/30] ACPI-processor: Improve another size determination in  acpi_processor_get_throttling_states() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-10 12:00 +0200
  [PATCH 10/30] ACPI-processor: Rename jump labels in  acpi_processor_get_performance_control() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-10 12:00 +0200
  [PATCH 16/30] ACPI-processor: Use kmalloc_array() in  acpi_processor_get_throttling_states() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-10 12:00 +0200
  [PATCH 11/30] ACPI-processor: Delete two unnecessary initialisations  in acpi_processor_get_performance_control() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-10 12:00 +0200
  [PATCH 09/30] ACPI-processor: Improve a size determination in  acpi_processor_get_psd() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-10 12:00 +0200
  [PATCH 14/30] ACPI-processor: Delete an unnecessary initialisation in  acpi_processor_get_performance_info() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-10 12:00 +0200
  Re: [PATCH 00/30] ACPI-processor: Fine-tuning for several function  implementations Paolo Bonzini <pbonzini@redhat.com> - 2016-09-10 12:00 +0200
  [PATCH 13/30] ACPI-processor: Delete an unnecessary initialisation in  acpi_processor_ppc_notifier() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-10 12:00 +0200
  [PATCH 12/30] ACPI-processor: Rename jump labels in  acpi_processor_ppc_notifier() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-10 12:00 +0200
  [PATCH 23/30] ACPI-processor: Improve a size determination in  acpi_processor_get_tsd() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-10 12:10 +0200
  [PATCH 25/30] ACPI-processor: Delete two unnecessary initialisations  in acpi_processor_get_throttling_control() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-10 12:10 +0200
  [PATCH 27/30] ACPI-processor: Delete an unnecessary initialisation in  acpi_processor_reevaluate_tstate() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-10 12:10 +0200
  [PATCH 26/30] ACPI-processor: Fix jump targets in  acpi_processor_reevaluate_tstate() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-10 12:10 +0200
  [PATCH 19/30] ACPI-processor: Delete two unnecessary initialisations  in acpi_processor_get_throttling_states() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-10 12:10 +0200
  [PATCH 18/30] ACPI-processor: Rename jump labels in  acpi_processor_get_throttling_states() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-10 12:10 +0200
  [PATCH 21/30] ACPI-processor: Rename jump labels in  acpi_processor_get_tsd() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-10 12:10 +0200
  [PATCH 22/30] ACPI-processor: Delete two unnecessary initialisations  in acpi_processor_get_tsd() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-10 12:10 +0200
  [PATCH 24/30] ACPI-processor: Rename jump labels in  acpi_processor_get_throttling_control() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-10 12:10 +0200
  [PATCH 20/30] ACPI-processor: Fix jump targets in  acpi_processor_get_throttling_info() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-10 12:10 +0200
  [PATCH 29/30] ACPI-processor: Delete an unnecessary initialisation in  acpi_processor_get_platform_limit() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-10 12:20 +0200
  [PATCH 28/30] ACPI-processor: Rename a jump label in  acpi_processor_get_platform_limit() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-10 12:20 +0200
  [PATCH 30/30] ACPI-processor: Improve jump targets in  acpi_processor_update_tsd_coord() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-10 12:20 +0200

csiph-web