lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <112064ca-41b3-6936-090a-3c229a251af7@users.sourceforge.net>
Date:   Fri, 9 Dec 2016 15:36:12 +0100
From:   SF Markus Elfring <elfring@...rs.sourceforge.net>
To:     devel@...verdev.osuosl.org, Alex Elder <elder@...nel.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Johan Hovold <johan@...nel.org>,
        Rui Miguel Silva <rmfrfs@...il.com>
Cc:     LKML <linux-kernel@...r.kernel.org>,
        kernel-janitors@...r.kernel.org
Subject: [PATCH 2/4] staging: greybus: light: Use kcalloc() in two functions

From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Fri, 9 Dec 2016 13:46:25 +0100

* Multiplications for the size determination of memory allocations
  indicated that array data structures should be processed.
  Thus use the corresponding function "kcalloc".

  This issue was detected by using the Coccinelle software.

* Replace the specification of data structures by pointer dereferences
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Fixes: 2870b52bae4c81823ffcb3ed2b0626fb39d64f48 ("greybus: lights: add lights implementation")

Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
---
 drivers/staging/greybus/light.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/greybus/light.c b/drivers/staging/greybus/light.c
index 8dffd8a7e762..27bfc20eb9a5 100644
--- a/drivers/staging/greybus/light.c
+++ b/drivers/staging/greybus/light.c
@@ -1030,9 +1030,9 @@ static int gb_lights_light_config(struct gb_lights *glights, u8 id)
 
 	light->channels_count = conf.channel_count;
 	light->name = kstrndup(conf.name, NAMES_MAX, GFP_KERNEL);
-
-	light->channels = kzalloc(light->channels_count *
-				  sizeof(struct gb_channel), GFP_KERNEL);
+	light->channels = kcalloc(light->channels_count,
+				  sizeof(*light->channels),
+				  GFP_KERNEL);
 	if (!light->channels)
 		return -ENOMEM;
 
@@ -1168,8 +1168,9 @@ static int gb_lights_create_all(struct gb_lights *glights)
 	if (ret < 0)
 		goto out;
 
-	glights->lights = kzalloc(glights->lights_count *
-				  sizeof(struct gb_light), GFP_KERNEL);
+	glights->lights = kcalloc(glights->lights_count,
+				  sizeof(*glights->lights),
+				  GFP_KERNEL);
 	if (!glights->lights) {
 		ret = -ENOMEM;
 		goto out;
-- 
2.11.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ