socket: Release cred reference later in sodealloc()

We dereference so->so_cred to update the per-uid socket buffer
accounting, so the crfree() call must be deferred until after that
point.

PR:		255869
MFC after:	1 week
This commit is contained in:
Lv Yunlong 2021-05-18 15:23:15 -04:00 committed by Mark Johnston
parent c4a6258d70
commit b295c5ddce

View File

@ -476,7 +476,6 @@ sodealloc(struct socket *so)
#endif
hhook_run_socket(so, NULL, HHOOK_SOCKET_CLOSE);
crfree(so->so_cred);
khelp_destroy_osd(&so->osd);
if (SOLISTENING(so)) {
if (so->sol_accept_filter != NULL)
@ -493,6 +492,7 @@ sodealloc(struct socket *so)
SOCKBUF_LOCK_DESTROY(&so->so_snd);
SOCKBUF_LOCK_DESTROY(&so->so_rcv);
}
crfree(so->so_cred);
mtx_destroy(&so->so_lock);
uma_zfree(socket_zone, so);
}