linuxkpi: Handle a NULL cache pointer in kmem_cache_destroy()

This is compatible with Linux, and some driver error paths depend on it.

Reviewed by:	bz, emaste
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D32337
This commit is contained in:
Mark Johnston 2021-10-06 14:45:22 -04:00
parent da3278ded3
commit a76de17715

View File

@ -193,6 +193,9 @@ lkpi_kmem_cache_free(struct linux_kmem_cache *c, void *m)
void
linux_kmem_cache_destroy(struct linux_kmem_cache *c)
{
if (c == NULL)
return;
if (unlikely(c->cache_flags & SLAB_TYPESAFE_BY_RCU)) {
/* make sure all free callbacks have been called */
rcu_barrier();