From c749a72feb60c7bfe519ebc42eab5b154e37d820 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 5 Apr 2019 01:03:04 +0000 Subject: [PATCH] scst/include/backport.h: Add a mempool_destroy() backport This patch makes it safe to call mempool_destroy(NULL) for kernel versions before v4.3. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8150 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/backport.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/scst/include/backport.h b/scst/include/backport.h index 6e9b92cd9..6b2273ced 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -815,6 +815,21 @@ static inline long get_user_pages_backport(unsigned long start, #define get_user_pages get_user_pages_backport #endif +/* */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0) +/* + * See also commit 4e3ca3e033d1 ("mm/mempool: allow NULL `pool' pointer in + * mempool_destroy()") # v4.3. + */ +static inline void mempool_destroy_backport(mempool_t *pool) +{ + if (pool) + mempool_destroy(pool); +} + +#define mempool_destroy mempool_destroy_backport +#endif + /* */ #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0) && \