Skip to content

Commit 027926f

Browse files
ihuguetgregkh
authored andcommitted
net:CXGB4: fix leak if sk_buff is not used
[ Upstream commit 52bfcdd ] 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 <ihuguet@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 9284b70 commit 027926f

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

  • drivers/net/ethernet/chelsio/cxgb4

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

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

25642564
next_state = CXGB4_EO_STATE_FLOWC_OPEN_SEND;
25652565
} else {
25662566
if (eosw_txq->state != CXGB4_EO_STATE_ACTIVE)
2567-
goto out_unlock;
2567+
goto out_free_skb;
25682568

25692569
next_state = CXGB4_EO_STATE_FLOWC_CLOSE_SEND;
25702570
}
@@ -2600,17 +2600,19 @@ int cxgb4_ethofld_send_flowc(struct net_device *dev, u32 eotid, u32 tc)
26002600
eosw_txq_flush_pending_skbs(eosw_txq);
26012601

26022602
ret = eosw_txq_enqueue(eosw_txq, skb);
2603-
if (ret) {
2604-
dev_consume_skb_any(skb);
2605-
goto out_unlock;
2606-
}
2603+
if (ret)
2604+
goto out_free_skb;
26072605

26082606
eosw_txq->state = next_state;
26092607
eosw_txq->flowc_idx = eosw_txq->pidx;
26102608
eosw_txq_advance(eosw_txq, 1);
26112609
ethofld_xmit(dev, eosw_txq);
26122610

2613-
out_unlock:
2611+
spin_unlock_bh(&eosw_txq->lock);
2612+
return 0;
2613+
2614+
out_free_skb:
2615+
dev_consume_skb_any(skb);
26142616
spin_unlock_bh(&eosw_txq->lock);
26152617
return ret;
26162618
}

0 commit comments

Comments
 (0)