Skip to content

Commit 00ffb37

Browse files
nifeykuba-moo
authored andcommitted
cxgb4: fix memory leak in cxgb4_init_ethtool_filters() error path
In the for loop used to allocate the loc_array and bmap for each port, a memory leak is possible when the allocation for loc_array succeeds, but the allocation for bmap fails. This is because when the control flow goes to the label free_eth_finfo, only the allocations starting from (i-1)th iteration are freed. Fix that by freeing the loc_array in the bmap allocation error path. Fixes: d915c29 ("cxgb4: add skeleton for ethtool n-tuple filters") Signed-off-by: Abdun Nihaal <[email protected]> Reviewed-by: Simon Horman <[email protected]> Reviewed-by: Jacob Keller <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent adf6b73 commit 00ffb37

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2270,6 +2270,7 @@ int cxgb4_init_ethtool_filters(struct adapter *adap)
22702270
eth_filter->port[i].bmap = bitmap_zalloc(nentries, GFP_KERNEL);
22712271
if (!eth_filter->port[i].bmap) {
22722272
ret = -ENOMEM;
2273+
kvfree(eth_filter->port[i].loc_array);
22732274
goto free_eth_finfo;
22742275
}
22752276
}

0 commit comments

Comments
 (0)