aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Elfring <elfring@users.sourceforge.net>2017-04-25 08:17:50 -0400
committerSebastian Reichel <sre@kernel.org>2017-06-08 07:21:43 -0400
commit67ddd75771b6b860bc0cebb3b7fd4cbebeda9cd4 (patch)
tree470eaf9150825fe46725563342eda337651e56b8
parentde7c98eb7c6f72bbfa87afc5b7e2d3b0188a8d83 (diff)
HSI: core: Use kcalloc() in two functions
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. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
-rw-r--r--drivers/hsi/hsi_core.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/hsi/hsi_core.c b/drivers/hsi/hsi_core.c
index c2a2a9795b0b..9065efd21851 100644
--- a/drivers/hsi/hsi_core.c
+++ b/drivers/hsi/hsi_core.c
@@ -267,14 +267,13 @@ static void hsi_add_client_from_dt(struct hsi_port *port,
267 267
268 cl->rx_cfg.num_channels = cells; 268 cl->rx_cfg.num_channels = cells;
269 cl->tx_cfg.num_channels = cells; 269 cl->tx_cfg.num_channels = cells;
270 270 cl->rx_cfg.channels = kcalloc(cells, sizeof(channel), GFP_KERNEL);
271 cl->rx_cfg.channels = kzalloc(cells * sizeof(channel), GFP_KERNEL);
272 if (!cl->rx_cfg.channels) { 271 if (!cl->rx_cfg.channels) {
273 err = -ENOMEM; 272 err = -ENOMEM;
274 goto err; 273 goto err;
275 } 274 }
276 275
277 cl->tx_cfg.channels = kzalloc(cells * sizeof(channel), GFP_KERNEL); 276 cl->tx_cfg.channels = kcalloc(cells, sizeof(channel), GFP_KERNEL);
278 if (!cl->tx_cfg.channels) { 277 if (!cl->tx_cfg.channels) {
279 err = -ENOMEM; 278 err = -ENOMEM;
280 goto err2; 279 goto err2;
@@ -485,7 +484,7 @@ struct hsi_controller *hsi_alloc_controller(unsigned int n_ports, gfp_t flags)
485 hsi = kzalloc(sizeof(*hsi), flags); 484 hsi = kzalloc(sizeof(*hsi), flags);
486 if (!hsi) 485 if (!hsi)
487 return NULL; 486 return NULL;
488 port = kzalloc(sizeof(*port)*n_ports, flags); 487 port = kcalloc(n_ports, sizeof(*port), flags);
489 if (!port) { 488 if (!port) {
490 kfree(hsi); 489 kfree(hsi);
491 return NULL; 490 return NULL;