Skip to contentSkip to conversation

staging: greybus: Use kcalloc for array's memory allocation.

PATCH In review Elise Lennion 2 participants 3 messages Oct 11, 2016 – Oct 12, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 6/7 staging: greybus: Use kcalloc for array's memory allocation.

Fix checkpatch warning:

WARNING: Prefer kcalloc over kzalloc with multiply

kcalloc is designed to allocate memory for arrays, its use is preferable than kzalloc in these cases.

---
 drivers/staging/greybus/camera.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/greybus/camera.c +2 -2
index 0c73445..1c5b41a 100644
@@ -797,7 +797,7 @@ static int gb_camera_op_configure_streams(void *priv, unsigned int *nstreams,
 	if (gb_nstreams > GB_CAMERA_MAX_STREAMS)
 		return -EINVAL;
 
-	gb_streams = kzalloc(gb_nstreams * sizeof(*gb_streams), GFP_KERNEL);
+	gb_streams = kcalloc(gb_nstreams, sizeof(*gb_streams), GFP_KERNEL);
 	if (!gb_streams)
 		return -ENOMEM;
 
@@ -938,7 +938,7 @@ static ssize_t gb_camera_debugfs_configure_streams(struct gb_camera *gcam,
 		return ret;
 
 	/* For each stream to configure parse width, height and format */
-	streams = kzalloc(nstreams * sizeof(*streams), GFP_KERNEL);
+	streams = kcalloc(nstreams, sizeof(*streams), GFP_KERNEL);
 	if (!streams)
 		return -ENOMEM;
 
Signature · 1 line
2.7.4
maintainer
#1 lore raw
Quoted 11 lines · Elise Lennion

Fix checkpatch warning:

WARNING: Prefer kcalloc over kzalloc with multiply

kcalloc is designed to allocate memory for arrays, its use is preferable than kzalloc in these cases.

---
 drivers/staging/greybus/camera.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Same issue with the subject:, it's the same as the previous patch.

A way to make it more unique would be to add the driver name to it, so for this one, it would be:
staging: greybus: camera: use kcalloc for array's memory

thanks,

greg k-h