Page MenuHomeFreeBSD

wtap: Remove bogus NULL check in wtap_transmit
ClosedPublic

Authored by enweiwu on Jan 6 2026, 12:40 AM.
Referenced Files
Unknown Object (File)
Thu, Jun 4, 11:14 AM
Unknown Object (File)
Thu, Jun 4, 9:25 AM
Unknown Object (File)
May 17 2026, 10:35 AM
Unknown Object (File)
May 17 2026, 12:52 AM
Unknown Object (File)
May 16 2026, 6:57 PM
Unknown Object (File)
May 13 2026, 5:25 PM
Unknown Object (File)
Apr 27 2026, 4:53 PM
Unknown Object (File)
Apr 27 2026, 11:43 AM

Details

Summary

The node pointer is guaranteed to be non-NULL by the net80211 stack.

The original check was also ineffective as it dereferenced ni->ni_vap before the NULL check.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Can you please create diffs with -U9999 if you manually upload them so there is context?

bz requested changes to this revision.Jan 6 2026, 12:56 AM
bz added inline comments.
sys/dev/wtap/if_wtap.c
594

The assumption that this can happen seems wrong. This should probably be a MPASS(ni != NULL); and we should be done with it.

Ignoring this for a minute if you look at ieee80211_parent_xmitpkt() which calls ic->ic_transmit you'll see that in the error case it does the cleanup (which does depend on the ni being valid) so be careful if you already free the mbuf (likely wrong). This is different to (*ic_raw_xmit) where you'd need to free the mbuf.

This revision now requires changes to proceed.Jan 6 2026, 12:56 AM
enweiwu added inline comments.
sys/dev/wtap/if_wtap.c
594

So, turns out the NULL check on the node ni is unnecessary in the first place. Let me revise the commit by removing the NULL check on the node ni.

enweiwu marked an inline comment as done.
enweiwu retitled this revision from wtap(4): Fix NULL pointer dereference in wtap_transmit to wtap: Remove bogus NULL check in wtap_transmit.
enweiwu edited the summary of this revision. (Show Details)
This revision is now accepted and ready to land.Mon, May 18, 5:55 PM
This revision was automatically updated to reflect the committed changes.