From: Hauke Mehrtens Date: Sat, 9 Aug 2014 12:00:29 +0000 (+0200) Subject: backports: add devm_kmalloc_array() X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=7b74819d3532a47bff0ca15b6c0fcaabca0287e3;p=openwrt%2Fstaging%2Fblogic.git backports: add devm_kmalloc_array() Signed-off-by: Hauke Mehrtens --- diff --git a/backport/backport-include/linux/device.h b/backport/backport-include/linux/device.h index 9ed73988e1af..830105df33fd 100644 --- a/backport/backport-include/linux/device.h +++ b/backport/backport-include/linux/device.h @@ -160,4 +160,15 @@ __ATTRIBUTE_GROUPS(_name) extern char *devm_kstrdup(struct device *dev, const char *s, gfp_t gfp); #endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0) +#define devm_kmalloc_array LINUX_BACKPORT(devm_kmalloc_array) +static inline void *devm_kmalloc_array(struct device *dev, + size_t n, size_t size, gfp_t flags) +{ + if (size != 0 && n > SIZE_MAX / size) + return NULL; + return devm_kmalloc(dev, n * size, flags); +} +#endif + #endif /* __BACKPORT_DEVICE_H */