From b8872139338c835e9876b826a7d3b6cbe8e7a403 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 9 Nov 2015 20:55:46 +0000 Subject: [PATCH] scst: Add a kmalloc_array() backport git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6638 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/backport.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scst/include/backport.h b/scst/include/backport.h index d8ce44ef3..53a2f55ab 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -401,6 +401,15 @@ static inline void sg_set_page(struct scatterlist *sg, struct page *page, (__flags), NULL, NULL) #endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 4, 0) +static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags) +{ + if (size != 0 && n > ULONG_MAX / size) + return NULL; + return kmalloc(n * size, flags); +} +#endif + /* */ #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 0)