linuxkpi: Add krealloc_array()
In FreeBSD, this is a wrapper on top of `realloc()`. V2: Check if `n * size` would overflow and return `NULL` if that's the case. Suggested by hselasky@ and emaste@. Reviewed by: manu Approved by: manu Differential Revision: https://reviews.freebsd.org/D36959
This commit is contained in:
parent
0b8a423d07
commit
1ad6b2b1da
@ -178,6 +178,16 @@ krealloc(void *ptr, size_t size, gfp_t flags)
|
||||
return (realloc(ptr, size, M_KMALLOC, linux_check_m_flags(flags)));
|
||||
}
|
||||
|
||||
static inline void *
|
||||
krealloc_array(void *ptr, size_t n, size_t size, gfp_t flags)
|
||||
{
|
||||
if (WOULD_OVERFLOW(n, size)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (realloc(ptr, n * size, M_KMALLOC, linux_check_m_flags(flags)));
|
||||
}
|
||||
|
||||
extern void linux_kfree_async(void *);
|
||||
|
||||
static inline void
|
||||
|
Loading…
x
Reference in New Issue
Block a user