Skip to content

Commit 52bfcdd

Browse files
ihuguetdavem330
authored andcommitted
net:CXGB4: fix leak if sk_buff is not used
An sk_buff is allocated to send a flow control message, but it's not sent in all cases: in case the state is not appropiate to send it or if it can't be enqueued. In the first of these 2 cases, the sk_buff was discarded but not freed, producing a memory leak. Signed-off-by: Íñigo Huguet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f941d68 commit 52bfcdd

File tree

1 file changed

+9
-7
lines changed
  • drivers/net/ethernet/chelsio/cxgb4

1 file changed

+9
-7
lines changed

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2563,12 +2563,12 @@ int cxgb4_ethofld_send_flowc(struct net_device *dev, u32 eotid, u32 tc)
25632563
spin_lock_bh(&eosw_txq->lock);
25642564
if (tc != FW_SCHED_CLS_NONE) {
25652565
if (eosw_txq->state != CXGB4_EO_STATE_CLOSED)
2566-
goto out_unlock;
2566+
goto out_free_skb;
25672567

25682568
next_state = CXGB4_EO_STATE_FLOWC_OPEN_SEND;
25692569
} else {
25702570
if (eosw_txq->state != CXGB4_EO_STATE_ACTIVE)
2571-
goto out_unlock;
2571+
goto out_free_skb;
25722572

25732573
next_state = CXGB4_EO_STATE_FLOWC_CLOSE_SEND;
25742574
}
@@ -2604,17 +2604,19 @@ int cxgb4_ethofld_send_flowc(struct net_device *dev, u32 eotid, u32 tc)
26042604
eosw_txq_flush_pending_skbs(eosw_txq);
26052605

26062606
ret = eosw_txq_enqueue(eosw_txq, skb);
2607-
if (ret) {
2608-
dev_consume_skb_any(skb);
2609-
goto out_unlock;
2610-
}
2607+
if (ret)
2608+
goto out_free_skb;
26112609

26122610
eosw_txq->state = next_state;
26132611
eosw_txq->flowc_idx = eosw_txq->pidx;
26142612
eosw_txq_advance(eosw_txq, 1);
26152613
ethofld_xmit(dev, eosw_txq);
26162614

2617-
out_unlock:
2615+
spin_unlock_bh(&eosw_txq->lock);
2616+
return 0;
2617+
2618+
out_free_skb:
2619+
dev_consume_skb_any(skb);
26182620
spin_unlock_bh(&eosw_txq->lock);
26192621
return ret;
26202622
}

0 commit comments

Comments
 (0)