Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 May 2019 18:08:19 +0000 (UTC)
From:      Dmitry Chagin <dchagin@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r348058 - head/sys/compat/linux
Message-ID:  <201905211808.x4LI8JU4037726@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dchagin
Date: Tue May 21 18:08:19 2019
New Revision: 348058
URL: https://svnweb.freebsd.org/changeset/base/348058

Log:
  Do not leak sa in linux_recvmsg() call if kern_recvit() fails.
  
  MFC after:	1 week

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

Modified: head/sys/compat/linux/linux_socket.c
==============================================================================
--- head/sys/compat/linux/linux_socket.c	Tue May 21 18:05:57 2019	(r348057)
+++ head/sys/compat/linux/linux_socket.c	Tue May 21 18:08:19 2019	(r348058)
@@ -1155,7 +1155,8 @@ linux_recvmsg_common(struct thread *td, l_int s, struc
 	if (msg->msg_name) {
 		sa = malloc(msg->msg_namelen, M_SONAME, M_WAITOK);
 		msg->msg_name = sa;
-	}
+	} else
+		sa = NULL;
 
 	uiov = msg->msg_iov;
 	msg->msg_iov = iov;
@@ -1172,7 +1173,6 @@ linux_recvmsg_common(struct thread *td, l_int s, struc
 			error = copyout(lsa, PTRIN(msg->msg_name),
 			    msg->msg_namelen);
 		free(lsa, M_SONAME);
-		free(sa, M_SONAME);
 		if (error != 0)
 			goto bad;
 	}
@@ -1292,6 +1292,7 @@ bad:
 	}
 	free(iov, M_IOV);
 	free(linux_cmsg, M_LINUX);
+	free(sa, M_SONAME);
 
 	return (error);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201905211808.x4LI8JU4037726>