svn commit: r283494 - head/sys/compat/linux

Dmitry Chagin dchagin at FreeBSD.org
Sun May 24 18:10:08 UTC 2015


Author: dchagin
Date: Sun May 24 18:10:07 2015
New Revision: 283494
URL: https://svnweb.freebsd.org/changeset/base/283494

Log:
  Fix an mbuf(9) leak in sendmsg() under failure condition and
  remove unneeded check for failed M_WAITOK allocation.
  
  Found by: Brainy Code Scanner
  Reported by: Maxime Villard

Modified:
  head/sys/compat/linux/linux_socket.c

Modified: head/sys/compat/linux/linux_socket.c
==============================================================================
--- head/sys/compat/linux/linux_socket.c	Sun May 24 18:09:01 2015	(r283493)
+++ head/sys/compat/linux/linux_socket.c	Sun May 24 18:10:07 2015	(r283494)
@@ -1092,8 +1092,6 @@ linux_sendmsg_common(struct thread *td, 
 		error = ENOBUFS;
 		cmsg = malloc(CMSG_HDRSZ, M_LINUX, M_WAITOK|M_ZERO);
 		control = m_get(M_WAITOK, MT_CONTROL);
-		if (control == NULL)
-			goto bad;
 
 		do {
 			error = copyin(ptr_cmsg, &linux_cmsg,
@@ -1165,6 +1163,7 @@ linux_sendmsg_common(struct thread *td, 
 	error = linux_sendit(td, s, &msg, flags, control, UIO_USERSPACE);
 
 bad:
+	m_freem(control);
 	free(iov, M_IOV);
 	if (cmsg)
 		free(cmsg, M_LINUX);


More information about the svn-src-all mailing list