Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Markus Elfring and committed by
Sebastian Reichel
67ddd757 de7c98eb

+3 -4
+3 -4
drivers/hsi/hsi_core.c
··· 267 267 268 268 cl->rx_cfg.num_channels = cells; 269 269 cl->tx_cfg.num_channels = cells; 270 - 271 - cl->rx_cfg.channels = kzalloc(cells * sizeof(channel), GFP_KERNEL); 270 + cl->rx_cfg.channels = kcalloc(cells, sizeof(channel), GFP_KERNEL); 272 271 if (!cl->rx_cfg.channels) { 273 272 err = -ENOMEM; 274 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 277 if (!cl->tx_cfg.channels) { 279 278 err = -ENOMEM; 280 279 goto err2; ··· 484 485 hsi = kzalloc(sizeof(*hsi), flags); 485 486 if (!hsi) 486 487 return NULL; 487 - port = kzalloc(sizeof(*port)*n_ports, flags); 488 + port = kcalloc(n_ports, sizeof(*port), flags); 488 489 if (!port) { 489 490 kfree(hsi); 490 491 return NULL;