bnxt_en: Fix aggregation buffer leak under OOM condition. [Linux 5.2]

bnxt_en: Fix aggregation buffer leak under OOM condition. [Linux 5.2]

This Linux kernel change "bnxt_en: Fix aggregation buffer leak under OOM condition" is included in the Linux 5.2 release. This change is authored by Michael Chan <michael.chan [at]> on Wed May 22 19:12:54 2019 -0400. The commit for this change in Linux stable tree is 296d5b5 (patch).

bnxt_en: Fix aggregation buffer leak under OOM condition.

For every RX packet, the driver replenishes all buffers used for that
packet and puts them back into the RX ring and RX aggregation ring.
In one code path where the RX packet has one RX buffer and one or more
aggregation buffers, we missed recycling the aggregation buffer(s) if
we are unable to allocate a new SKB buffer.  This leads to the
aggregation ring slowly running out of buffers over time.  Fix it
by properly recycling the aggregation buffers.

Fixes: c0c050c58d84 ("bnxt_en: New Broadcom ethernet driver.")
Reported-by: Rakesh Hemnani <[email protected]>
Signed-off-by: Michael Chan <[email protected]>
Signed-off-by: David S. Miller <[email protected]>

There are 2 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 8314c00..21f6826 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -1642,6 +1642,8 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
        skb = bnxt_copy_skb(bnapi, data_ptr, len, dma_addr);
        bnxt_reuse_rx_data(rxr, cons, data);
        if (!skb) {
+           if (agg_bufs)
+               bnxt_reuse_rx_agg_bufs(cpr, cp_cons, agg_bufs);
            rc = -ENOMEM;
            goto next_rx;

Leave a Reply

Your email address will not be published. Required fields are marked *