Skip to content

Commit

Permalink
octeontx2-af: Fix some memory leaks in the error handling path of 'cg…
Browse files Browse the repository at this point in the history
…x_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 <christophe.jaillet@wanadoo.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Christophe JAILLET authored and David S. Miller committed Sep 4, 2021
1 parent d863ca6 commit ecbd690
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions drivers/net/ethernet/marvell/octeontx2/af/cgx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1487,7 +1487,7 @@ static int cgx_lmac_init(struct cgx *cgx)
MAX_DMAC_ENTRIES_PER_CGX / cgx->lmac_count;
err = rvu_alloc_bitmap(&lmac->mac_to_index_bmap);
if (err)
return err;
goto err_name_free;

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

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

return cgx_lmac_verify_fwi_version(cgx);

err_irq:
err_bitmap_free:
rvu_free_bitmap(&lmac->mac_to_index_bmap);
err_name_free:
kfree(lmac->name);
err_lmac_free:
kfree(lmac);
Expand Down

0 comments on commit ecbd690

Please sign in to comment.