From e49d57eecc8e4cb2247fc667928e91f62d392ca0 Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Wed, 6 Oct 2021 14:45:22 -0400 Subject: [PATCH] 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 Sponsored by: The FreeBSD Foundation (cherry picked from commit a76de17715ab689b0b53a1012e22d8a08470b6e4) --- sys/compat/linuxkpi/common/src/linux_slab.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/compat/linuxkpi/common/src/linux_slab.c b/sys/compat/linuxkpi/common/src/linux_slab.c index 35a88fd7cf4..0aa751ec886 100644 --- a/sys/compat/linuxkpi/common/src/linux_slab.c +++ b/sys/compat/linuxkpi/common/src/linux_slab.c @@ -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();