From 5cf32a6e95e62625ca5ea6b5564c371276956210 Mon Sep 17 00:00:00 2001 From: Kristof Provost Date: Sun, 7 Jan 2018 13:41:06 +0000 Subject: [PATCH] vchiq: Use mallocarray() to provide kcalloc() This means we now also provide integer overflow protection, like the Linux kcalloc(). --- sys/contrib/vchiq/interface/compat/vchi_bsd.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/contrib/vchiq/interface/compat/vchi_bsd.h b/sys/contrib/vchiq/interface/compat/vchi_bsd.h index 107041ac37b9..a02bca452756 100644 --- a/sys/contrib/vchiq/interface/compat/vchi_bsd.h +++ b/sys/contrib/vchiq/interface/compat/vchi_bsd.h @@ -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)