HomeFreeBSD

bridge: Fix a potential memory leak in bridge_enqueue()

Description

bridge: Fix a potential memory leak in bridge_enqueue()

A comment at the beginning of the function notes that we may be
transmitting multiple fragments as distinct packets. So, the function
loops over all fragments, transmitting each mbuf chain. If if_transmit
fails, we need to free all of the fragments, but m_freem() only frees an
mbuf chain - it doesn't follow m_nextpkt.

Change the error handler to free each untransmitted packet fragment, and
count each fragment as a separate error since we increment OPACKETS once
per fragment when transmission is successful.

Reviewed by: zlei, kp
MFC after: 1 week
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D37635

(cherry picked from commit 51088797305c8aba43e8ded60b99eef5baa14071)

Details

Provenance
markjAuthored on Dec 11 2022, 4:40 PM
Reviewer
zlei
Differential Revision
D37635: bridge: Fix a potential memory leak in bridge_enqueue()
Parents
rG98492960c3d9: libdtrace: Change the binding of USDT probe symbols to STB_WEAK
Branches
Unknown
Tags
Unknown