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
This commit is contained in:
Bart Van Assche
2019-04-05 01:03:04 +00:00
parent b011fdf316
commit c749a72feb

View File

@@ -815,6 +815,21 @@ static inline long get_user_pages_backport(unsigned long start,
#define get_user_pages get_user_pages_backport
#endif
/* <linux/mempoool.h> */
#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
/* <linux/mm.h> */
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0) && \