scst/include/backport.h: Add a kmem_cache_destroy() backport

This patch makes it safe to call kmem_cache_destroy(NULL) on kernel v4.2
and before.


git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8149 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2019-04-04 00:37:15 +00:00
parent 3796f42abb
commit b011fdf316

View File

@@ -1302,6 +1302,20 @@ static inline void sg_unmark_end(struct scatterlist *sg)
(__flags), NULL, NULL)
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0)
/*
* See also commit 3942d2991852 ("mm/slab_common: allow NULL cache pointer in
* kmem_cache_destroy()") # v4.3.
*/
static inline void kmem_cache_destroy_backport(struct kmem_cache *s)
{
if (s)
kmem_cache_destroy(s);
}
#define kmem_cache_destroy kmem_cache_destroy_backport
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 4, 0) && \
!(LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 52) && \
LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)) && \