net: ethernet: ti: cpsw_ale: Fix access to un-initialized memory
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Mon, 8 Nov 2021 21:28:55 +0000 (22:28 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 10 Nov 2021 14:33:04 +0000 (14:33 +0000)
It is spurious to allocate a bitmap without initializing it.
So, better safe than sorry, initialize it to 0 at least to have some known
values.

While at it, switch to the devm_bitmap_ API which is less verbose.

Fixes: 4b41d3436796 ("net: ethernet: ti: cpsw: allow untagged traffic on host port")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/ti/cpsw_ale.c

index 0c75e0576ee1f0817e1212ed3b785ed57b99e610..1ef0aaef5c61cd25d8b10c1e5396c622196a8b87 100644 (file)
@@ -1299,10 +1299,8 @@ struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params)
        if (!ale)
                return ERR_PTR(-ENOMEM);
 
-       ale->p0_untag_vid_mask =
-               devm_kmalloc_array(params->dev, BITS_TO_LONGS(VLAN_N_VID),
-                                  sizeof(unsigned long),
-                                  GFP_KERNEL);
+       ale->p0_untag_vid_mask = devm_bitmap_zalloc(params->dev, VLAN_N_VID,
+                                                   GFP_KERNEL);
        if (!ale->p0_untag_vid_mask)
                return ERR_PTR(-ENOMEM);