linuxkpi: Passing a size of zero to krealloc() frees the pointer

This matches the API on Linux.

Reviewed by:	bz
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D56452
This commit is contained in:
Jean-Sébastien Pédron
2026-04-14 02:00:23 +02:00
parent bbd20c0795
commit 2434fcfd0d
@@ -250,6 +250,11 @@ lkpi_krealloc(const void *ptr, size_t size, gfp_t flags)
if (ptr == NULL)
return (kmalloc(size, flags));
if (size == 0) {
kfree(ptr);
return (ZERO_SIZE_PTR);
}
osize = ksize(ptr);
if (size <= osize)
return (__DECONST(void *, ptr));