Skip to content

Commit ecbd690

Browse files
tititiou36davem330
authored andcommitted
octeontx2-af: Fix some memory leaks in the error handling path of 'cgx_lmac_init()'
Memory allocated before 'lmac' is stored in 'cgx->lmac_idmap[]' must be freed explicitly. Otherwise, in case of error, it will leak. Rename the 'err_irq' label to better describe what is done at this place in the error handling path. Fixes: 6f14078 ("octeontx2-af: DMAC filter support in MAC block") Signed-off-by: Christophe JAILLET <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d863ca6 commit ecbd690

File tree

1 file changed

+5
-3
lines changed
  • drivers/net/ethernet/marvell/octeontx2/af

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,7 +1487,7 @@ static int cgx_lmac_init(struct cgx *cgx)
14871487
MAX_DMAC_ENTRIES_PER_CGX / cgx->lmac_count;
14881488
err = rvu_alloc_bitmap(&lmac->mac_to_index_bmap);
14891489
if (err)
1490-
return err;
1490+
goto err_name_free;
14911491

14921492
/* Reserve first entry for default MAC address */
14931493
set_bit(0, lmac->mac_to_index_bmap.bmap);
@@ -1497,7 +1497,7 @@ static int cgx_lmac_init(struct cgx *cgx)
14971497
spin_lock_init(&lmac->event_cb_lock);
14981498
err = cgx_configure_interrupt(cgx, lmac, lmac->lmac_id, false);
14991499
if (err)
1500-
goto err_irq;
1500+
goto err_bitmap_free;
15011501

15021502
/* Add reference */
15031503
cgx->lmac_idmap[lmac->lmac_id] = lmac;
@@ -1507,7 +1507,9 @@ static int cgx_lmac_init(struct cgx *cgx)
15071507

15081508
return cgx_lmac_verify_fwi_version(cgx);
15091509

1510-
err_irq:
1510+
err_bitmap_free:
1511+
rvu_free_bitmap(&lmac->mac_to_index_bmap);
1512+
err_name_free:
15111513
kfree(lmac->name);
15121514
err_lmac_free:
15131515
kfree(lmac);

0 commit comments

Comments
 (0)