HomeFreeBSD

tcp_usrreq: Free allocated buffer in relock case

Description

tcp_usrreq: Free allocated buffer in relock case

The disgusting macro INP_WLOCK_RECHECK may early-return. In
tcp_default_ctloutput() the TCP_CCALGOOPT case allocates memory before invoking
this macro, which may leak memory.

Add a _CLEANUP variant that takes a code argument to perform variable cleanup
in the early return path. Use it to free the 'pbuf' allocated in
tcp_default_ctloutput().

I am not especially happy with this macro, but I reckon it's not any worse than
INP_WLOCK_RECHECK already was.

Reported by: Coverity
CID: 1350286
Sponsored by: EMC / Isilon Storage Division

Details

Provenance
cemAuthored on
Parents
rS298672: g_part_bsd64: Delete duplicate/dead code
Branches
Unknown
Tags
Unknown