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>
This commit is contained in:
parent
de7c98eb7c
commit
67ddd75771
1 changed files with 3 additions and 4 deletions
|
@ -267,14 +267,13 @@ static void hsi_add_client_from_dt(struct hsi_port *port,
|
||||||
|
|
||||||
cl->rx_cfg.num_channels = cells;
|
cl->rx_cfg.num_channels = cells;
|
||||||
cl->tx_cfg.num_channels = cells;
|
cl->tx_cfg.num_channels = cells;
|
||||||
|
cl->rx_cfg.channels = kcalloc(cells, sizeof(channel), GFP_KERNEL);
|
||||||
cl->rx_cfg.channels = kzalloc(cells * sizeof(channel), GFP_KERNEL);
|
|
||||||
if (!cl->rx_cfg.channels) {
|
if (!cl->rx_cfg.channels) {
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl->tx_cfg.channels = kzalloc(cells * sizeof(channel), GFP_KERNEL);
|
cl->tx_cfg.channels = kcalloc(cells, sizeof(channel), GFP_KERNEL);
|
||||||
if (!cl->tx_cfg.channels) {
|
if (!cl->tx_cfg.channels) {
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
goto err2;
|
goto err2;
|
||||||
|
@ -485,7 +484,7 @@ struct hsi_controller *hsi_alloc_controller(unsigned int n_ports, gfp_t flags)
|
||||||
hsi = kzalloc(sizeof(*hsi), flags);
|
hsi = kzalloc(sizeof(*hsi), flags);
|
||||||
if (!hsi)
|
if (!hsi)
|
||||||
return NULL;
|
return NULL;
|
||||||
port = kzalloc(sizeof(*port)*n_ports, flags);
|
port = kcalloc(n_ports, sizeof(*port), flags);
|
||||||
if (!port) {
|
if (!port) {
|
||||||
kfree(hsi);
|
kfree(hsi);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in a new issue