HSI: core: Use kcalloc() in two functions
authorMarkus Elfring <[email protected]>
Tue, 25 Apr 2017 12:17:50 +0000 (14:17 +0200)
committerSebastian Reichel <[email protected]>
Thu, 8 Jun 2017 11:21:43 +0000 (13:21 +0200)
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 <[email protected]>
Signed-off-by: Sebastian Reichel <[email protected]>
drivers/hsi/hsi_core.c

index c2a2a9795b0ba8057bacddcd33d52a8b00ae545b..9065efd21851df91b54f3e69814743d1766825d1 100644 (file)
@@ -267,14 +267,13 @@ static void hsi_add_client_from_dt(struct hsi_port *port,
 
        cl->rx_cfg.num_channels = cells;
        cl->tx_cfg.num_channels = cells;
-
-       cl->rx_cfg.channels = kzalloc(cells * sizeof(channel), GFP_KERNEL);
+       cl->rx_cfg.channels = kcalloc(cells, sizeof(channel), GFP_KERNEL);
        if (!cl->rx_cfg.channels) {
                err = -ENOMEM;
                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) {
                err = -ENOMEM;
                goto err2;
@@ -485,7 +484,7 @@ struct hsi_controller *hsi_alloc_controller(unsigned int n_ports, gfp_t flags)
        hsi = kzalloc(sizeof(*hsi), flags);
        if (!hsi)
                return NULL;
-       port = kzalloc(sizeof(*port)*n_ports, flags);
+       port = kcalloc(n_ports, sizeof(*port), flags);
        if (!port) {
                kfree(hsi);
                return NULL;