Fix mbuf leaks after reception error in rge_rxeof().
authorkevlo <kevlo@openbsd.org>
Tue, 23 Nov 2021 01:44:44 +0000 (01:44 +0000)
committerkevlo <kevlo@openbsd.org>
Tue, 23 Nov 2021 01:44:44 +0000 (01:44 +0000)
Being that rge(4) is derived from re(4) it looks like it has the same
issues as fixed in re(4) rev 1.211.

From Brad
ok gnezdo@

sys/dev/pci/if_rge.c

index 6d54456..4ef95f6 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: if_rge.c,v 1.15 2021/08/16 01:30:27 kevlo Exp $       */
+/*     $OpenBSD: if_rge.c,v 1.16 2021/11/23 01:44:44 kevlo Exp $       */
 
 /*
  * Copyright (c) 2019, 2020 Kevin Lo <kevlo@openbsd.org>
@@ -1223,6 +1223,8 @@ rge_rxeof(struct rge_queues *q)
 
                if ((rxstat & (RGE_RDCMDSTS_SOF | RGE_RDCMDSTS_EOF)) !=
                    (RGE_RDCMDSTS_SOF | RGE_RDCMDSTS_EOF)) {
+                       ifp->if_ierrors++;
+                       m_freem(m);
                        rge_discard_rxbuf(q, i);
                        continue;
                }
@@ -1237,6 +1239,7 @@ rge_rxeof(struct rge_queues *q)
                                m_freem(q->q_rx.rge_head);
                                q->q_rx.rge_head = q->q_rx.rge_tail = NULL;
                        }
+                       m_freem(m);
                        rge_discard_rxbuf(q, i);
                        continue;
                }