vchiq: Use mallocarray() to provide kcalloc()

This means we now also provide integer overflow protection, like the
Linux kcalloc().
This commit is contained in:
kp 2018-01-07 13:41:06 +00:00
parent 51600b48e4
commit 849a5573cb

View File

@ -329,7 +329,8 @@ device_rlprintf(int pps, device_t dev, const char *fmt, ...)
MALLOC_DECLARE(M_VCHI); MALLOC_DECLARE(M_VCHI);
#define kmalloc(size, flags) malloc((size), M_VCHI, M_NOWAIT | M_ZERO) #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 kzalloc(a, b) kcalloc(1, (a), (b))
#define kfree(p) free(p, M_VCHI) #define kfree(p) free(p, M_VCHI)