Skip to content

Commit db010ff

Browse files
rkannoth1Paolo Abeni
authored andcommitted
octeontx2-af: Initialize maps.
kmalloc_array() without __GFP_ZERO flag does not initialize memory to zero. This causes issues. Use kcalloc() for maps and bitmap_zalloc() for bitmaps. Fixes: dd78428 ("octeontx2-af: Add new devlink param to configure maximum usable NIX block LFs") Signed-off-by: Ratheesh Kannoth <[email protected]> Reviewed-by: Brett Creeley <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 03fa49a commit db010ff

File tree

1 file changed

+15
-16
lines changed
  • drivers/net/ethernet/marvell/octeontx2/af

1 file changed

+15
-16
lines changed

drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1850,8 +1850,8 @@ void npc_mcam_rsrcs_deinit(struct rvu *rvu)
18501850
{
18511851
struct npc_mcam *mcam = &rvu->hw->mcam;
18521852

1853-
kfree(mcam->bmap);
1854-
kfree(mcam->bmap_reverse);
1853+
bitmap_free(mcam->bmap);
1854+
bitmap_free(mcam->bmap_reverse);
18551855
kfree(mcam->entry2pfvf_map);
18561856
kfree(mcam->cntr2pfvf_map);
18571857
kfree(mcam->entry2cntr_map);
@@ -1904,21 +1904,20 @@ int npc_mcam_rsrcs_init(struct rvu *rvu, int blkaddr)
19041904
mcam->pf_offset = mcam->nixlf_offset + nixlf_count;
19051905

19061906
/* Allocate bitmaps for managing MCAM entries */
1907-
mcam->bmap = kmalloc_array(BITS_TO_LONGS(mcam->bmap_entries),
1908-
sizeof(long), GFP_KERNEL);
1907+
mcam->bmap = bitmap_zalloc(mcam->bmap_entries, GFP_KERNEL);
19091908
if (!mcam->bmap)
19101909
return -ENOMEM;
19111910

1912-
mcam->bmap_reverse = kmalloc_array(BITS_TO_LONGS(mcam->bmap_entries),
1913-
sizeof(long), GFP_KERNEL);
1911+
mcam->bmap_reverse = bitmap_zalloc(mcam->bmap_entries, GFP_KERNEL);
19141912
if (!mcam->bmap_reverse)
19151913
goto free_bmap;
19161914

19171915
mcam->bmap_fcnt = mcam->bmap_entries;
19181916

19191917
/* Alloc memory for saving entry to RVU PFFUNC allocation mapping */
1920-
mcam->entry2pfvf_map = kmalloc_array(mcam->bmap_entries,
1921-
sizeof(u16), GFP_KERNEL);
1918+
mcam->entry2pfvf_map = kcalloc(mcam->bmap_entries, sizeof(u16),
1919+
GFP_KERNEL);
1920+
19221921
if (!mcam->entry2pfvf_map)
19231922
goto free_bmap_reverse;
19241923

@@ -1941,21 +1940,21 @@ int npc_mcam_rsrcs_init(struct rvu *rvu, int blkaddr)
19411940
if (err)
19421941
goto free_entry_map;
19431942

1944-
mcam->cntr2pfvf_map = kmalloc_array(mcam->counters.max,
1945-
sizeof(u16), GFP_KERNEL);
1943+
mcam->cntr2pfvf_map = kcalloc(mcam->counters.max, sizeof(u16),
1944+
GFP_KERNEL);
19461945
if (!mcam->cntr2pfvf_map)
19471946
goto free_cntr_bmap;
19481947

19491948
/* Alloc memory for MCAM entry to counter mapping and for tracking
19501949
* counter's reference count.
19511950
*/
1952-
mcam->entry2cntr_map = kmalloc_array(mcam->bmap_entries,
1953-
sizeof(u16), GFP_KERNEL);
1951+
mcam->entry2cntr_map = kcalloc(mcam->bmap_entries, sizeof(u16),
1952+
GFP_KERNEL);
19541953
if (!mcam->entry2cntr_map)
19551954
goto free_cntr_map;
19561955

1957-
mcam->cntr_refcnt = kmalloc_array(mcam->counters.max,
1958-
sizeof(u16), GFP_KERNEL);
1956+
mcam->cntr_refcnt = kcalloc(mcam->counters.max, sizeof(u16),
1957+
GFP_KERNEL);
19591958
if (!mcam->cntr_refcnt)
19601959
goto free_entry_cntr_map;
19611960

@@ -1988,9 +1987,9 @@ int npc_mcam_rsrcs_init(struct rvu *rvu, int blkaddr)
19881987
free_entry_map:
19891988
kfree(mcam->entry2pfvf_map);
19901989
free_bmap_reverse:
1991-
kfree(mcam->bmap_reverse);
1990+
bitmap_free(mcam->bmap_reverse);
19921991
free_bmap:
1993-
kfree(mcam->bmap);
1992+
bitmap_free(mcam->bmap);
19941993

19951994
return -ENOMEM;
19961995
}

0 commit comments

Comments
 (0)