Skip to content

Commit

Permalink
ibmvnic: free tx_pool if tso_pool alloc fails
Browse files Browse the repository at this point in the history
Free tx_pool and clear it, if allocation of tso_pool fails.

release_tx_pools() assumes we have both tx and tso_pools if ->tx_pool is
non-NULL. If allocation of tso_pool fails in init_tx_pools(), the assumption
will not be true and we would end up dereferencing ->tx_buff, ->free_map
fields from a NULL pointer.

Fixes: 3205306 ("ibmvnic: Update TX pool initialization routine")
Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Sukadev Bhattiprolu authored and David S. Miller committed Jun 24, 2021
1 parent 552a337 commit f6ebca8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/net/ethernet/ibm/ibmvnic.c
Original file line number Diff line number Diff line change
Expand Up @@ -778,8 +778,11 @@ static int init_tx_pools(struct net_device *netdev)

adapter->tso_pool = kcalloc(tx_subcrqs,
sizeof(struct ibmvnic_tx_pool), GFP_KERNEL);
if (!adapter->tso_pool)
if (!adapter->tso_pool) {
kfree(adapter->tx_pool);
adapter->tx_pool = NULL;
return -1;
}

adapter->num_active_tx_pools = tx_subcrqs;

Expand Down

0 comments on commit f6ebca8

Please sign in to comment.