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


Groups > linux.kernel > #1625617

[PATCH 1/3] ata: libahci: Use kcalloc() in ahci_platform_get_resources()

From SF Markus Elfring <elfring@users.sourceforge.net>
Newsgroups linux.kernel
Subject [PATCH 1/3] ata: libahci: Use kcalloc() in ahci_platform_get_resources()
Date 2017-04-18 22:10 +0200
Message-ID <txHBM-22s-13@gated-at.bofh.it> (permalink)
References <txHBL-22s-5@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 21:07:34 +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 "kcalloc".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/ata/libahci_platform.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/ata/libahci_platform.c b/drivers/ata/libahci_platform.c
index aaa761b9081c..c68ea903b5bf 100644
--- a/drivers/ata/libahci_platform.c
+++ b/drivers/ata/libahci_platform.c
@@ -408,8 +408,9 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev)
 		rc = -ENOMEM;
 		goto err_out;
 	}
-	sz = hpriv->nports * sizeof(*hpriv->target_pwrs);
-	hpriv->target_pwrs = kzalloc(sz, GFP_KERNEL);
+	hpriv->target_pwrs = kcalloc(hpriv->nports,
+				     sizeof(*hpriv->target_pwrs),
+				     GFP_KERNEL);
 	if (!hpriv->target_pwrs) {
 		rc = -ENOMEM;
 		goto err_out;
-- 
2.12.2

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


Thread

[PATCH 0/3] SATA: Fine-tuning for two function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-18 22:10 +0200
  [PATCH 2/3] ata: libahci: Use devm_kcalloc() in  ahci_platform_get_resources() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-18 22:10 +0200
  [PATCH 1/3] ata: libahci: Use kcalloc() in  ahci_platform_get_resources() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-18 22:10 +0200

csiph-web