git: 636420bde362 - main - unix/dgram: don't leak file descriptors when socket write failed

From: Gleb Smirnoff <glebius_at_FreeBSD.org>
Date: Fri, 30 Sep 2022 20:45:03 UTC
The branch main has been updated by glebius:

URL: https://cgit.FreeBSD.org/src/commit/?id=636420bde36282c4d9c8855e56fdc3601e192129

commit 636420bde36282c4d9c8855e56fdc3601e192129
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2022-09-30 20:26:14 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2022-09-30 20:43:08 +0000

    unix/dgram: don't leak file descriptors when socket write failed
---
 sys/kern/uipc_usrreq.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c
index 00d7aa1fc968..0c6d41ddca10 100644
--- a/sys/kern/uipc_usrreq.c
+++ b/sys/kern/uipc_usrreq.c
@@ -1338,6 +1338,8 @@ uipc_sosend_dgram(struct socket *so, struct sockaddr *addr, struct uio *uio,
 	} else {
 		soroverflow_locked(so2);
 		error = (so->so_state & SS_NBIO) ? EAGAIN : ENOBUFS;
+		if (f->m_next->m_type == MT_CONTROL)
+			unp_scan(f->m_next, unp_freerights);
 	}
 
 	if (addr != NULL)