svn commit: r327677 - head/sys/contrib/vchiq/interface/compat

Kristof Provost kp at FreeBSD.org
Sun Jan 7 13:41:07 UTC 2018


Author: kp
Date: Sun Jan  7 13:41:06 2018
New Revision: 327677
URL: https://svnweb.freebsd.org/changeset/base/327677

Log:
  vchiq: Use mallocarray() to provide kcalloc()
  
  This means we now also provide integer overflow protection, like the
  Linux kcalloc().

Modified:
  head/sys/contrib/vchiq/interface/compat/vchi_bsd.h

Modified: head/sys/contrib/vchiq/interface/compat/vchi_bsd.h
==============================================================================
--- head/sys/contrib/vchiq/interface/compat/vchi_bsd.h	Sun Jan  7 13:39:12 2018	(r327676)
+++ head/sys/contrib/vchiq/interface/compat/vchi_bsd.h	Sun Jan  7 13:41:06 2018	(r327677)
@@ -329,7 +329,8 @@ device_rlprintf(int pps, device_t dev, const char *fmt
 MALLOC_DECLARE(M_VCHI);
 
 #define kmalloc(size, flags)	malloc((size), M_VCHI, M_NOWAIT | M_ZERO)
-#define kcalloc(n, size, flags)	malloc((n) * (size), M_VCHI, M_NOWAIT | M_ZERO)
+#define kcalloc(n, size, flags)	mallocarray((n), (size), M_VCHI, \
+				    M_NOWAIT | M_ZERO)
 #define kzalloc(a, b)		kcalloc(1, (a), (b))
 #define kfree(p)		free(p, M_VCHI)
 


More information about the svn-src-head mailing list