vchiq: Use mallocarray() to provide kcalloc()

This means we now also provide integer overflow protection, like the
Linux kcalloc().
This commit is contained in:
Kristof Provost 2018-01-07 13:41:06 +00:00
parent e70c77ca17
commit 5cf32a6e95

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)