Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Aug 2020 15:54:58 +0000 (UTC)
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r364698 - stable/12/sys/compat/linux
Message-ID:  <202008241554.07OFswwa055158@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trasz
Date: Mon Aug 24 15:54:58 2020
New Revision: 364698
URL: https://svnweb.freebsd.org/changeset/base/364698

Log:
  MFC r348058 by dchagin:
  
  Do not leak sa in linux_recvmsg() call if kern_recvit() fails.

Modified:
  stable/12/sys/compat/linux/linux_socket.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/compat/linux/linux_socket.c
==============================================================================
--- stable/12/sys/compat/linux/linux_socket.c	Mon Aug 24 15:53:52 2020	(r364697)
+++ stable/12/sys/compat/linux/linux_socket.c	Mon Aug 24 15:54:58 2020	(r364698)
@@ -1162,7 +1162,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;
@@ -1179,7 +1180,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;
 	}
@@ -1299,6 +1299,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?202008241554.07OFswwa055158>