[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <11086550-7b2b-9284-1512-fb501904f8a2@users.sourceforge.net>
Date: Tue, 18 Apr 2017 22:01:45 +0200
From: SF Markus Elfring <elfring@...rs.sourceforge.net>
To: linux-ide@...r.kernel.org, Hans de Goede <hdegoede@...hat.com>,
Tejun Heo <tj@...nel.org>
Cc: LKML <linux-kernel@...r.kernel.org>,
kernel-janitors@...r.kernel.org
Subject: [PATCH 1/3] ata: libahci: Use kcalloc() in
ahci_platform_get_resources()
From: Markus Elfring <elfring@...rs.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@...rs.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
Powered by blists - more mailing lists