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


Groups > linux.kernel > #1625462

[PATCH 1/6] ACPI-fan: Use devm_kcalloc() in acpi_fan_get_fps()

From SF Markus Elfring <elfring@users.sourceforge.net>
Newsgroups linux.kernel
Subject [PATCH 1/6] ACPI-fan: Use devm_kcalloc() in acpi_fan_get_fps()
Date 2017-04-18 19:00 +0200
Message-ID <txEDU-8uq-19@gated-at.bofh.it> (permalink)
References <txEue-8r4-19@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Apr 2017 17:00:39 +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 "devm_kcalloc".

* 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/fan.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index 6cf4988206f2..92878c7c523b 100644
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@ -298,8 +298,7 @@ static int acpi_fan_get_fps(struct acpi_device *device)
 	}
 
 	fan->fps_count = obj->package.count - 1; /* minus revision field */
-	fan->fps = devm_kzalloc(&device->dev,
-				fan->fps_count * sizeof(struct acpi_fan_fps),
+	fan->fps = devm_kcalloc(&device->dev, fan->fps_count, sizeof(*fan->fps),
 				GFP_KERNEL);
 	if (!fan->fps) {
 		dev_err(&device->dev, "Not enough memory\n");
-- 
2.12.2

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


Thread

[PATCH 0/6] ACPI: Fine-tuning for some function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-18 18:50 +0200
  [PATCH 6/6] ACPI-proc: Replace two seq_printf() calls by seq_puts()  in acpi_system_wakeup_device_seq_show() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-18 19:00 +0200
  [PATCH 2/6] ACPI-fan: Delete error messages for a failed memory  allocation in two functions SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-18 19:00 +0200
  [PATCH 5/6] ACPI-battery: Replace 16 seq_printf() calls by seq_puts() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-18 19:00 +0200
  [PATCH 1/6] ACPI-fan: Use devm_kcalloc() in acpi_fan_get_fps() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-18 19:00 +0200
  [PATCH 4/6] ACPI-APEI-EINJ: Replace 12 seq_printf() calls by  seq_puts() in available_error_type_show() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-18 19:00 +0200
  [PATCH 3/6] ACPI-nfit: Use devm_kcalloc() in nfit_mem_dcr_init() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-18 19:00 +0200

csiph-web