From 6c4338f2ef3b36c050a85514eb2b67f48066687b Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Wed, 4 Jan 2017 16:09:45 +0000 Subject: [PATCH] The callers of kern_getfsstat(UIO_SYSSPACE) expect that *buf always returns memory which must be freed, regardless of the error. Assign NULL to *buf in case we are not going to allocate any memory due to invalid mode. Reported and tested by: pho Reviewed by: jhb Sponsored by: The FreeBSD Foundation MFC after: 3 weeks (together with r310638) Differential revision: https://reviews.freebsd.org/D9042 --- sys/kern/vfs_syscalls.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index b51122aacc39..6407732c9548 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -429,6 +429,8 @@ kern_getfsstat(struct thread *td, struct statfs **buf, size_t bufsize, case MNT_NOWAIT: break; default: + if (bufseg == UIO_SYSSPACE) + *buf = NULL; return (EINVAL); } restart: