aboutsummaryrefslogtreecommitdiff
path: root/include/drm/drm_managed.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/drm/drm_managed.h')
-rw-r--r--include/drm/drm_managed.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/include/drm/drm_managed.h b/include/drm/drm_managed.h
index 2d1e29a2200c..191d8d206ff4 100644
--- a/include/drm/drm_managed.h
+++ b/include/drm/drm_managed.h
@@ -4,6 +4,7 @@
#define _DRM_MANAGED_H_
#include <linux/gfp.h>
+#include <linux/overflow.h>
#include <linux/types.h>
struct drm_device;
@@ -31,6 +32,21 @@ static inline void *drmm_kzalloc(struct drm_device *dev, size_t size, gfp_t gfp)
{
return drmm_kmalloc(dev, size, gfp | __GFP_ZERO);
}
+static inline void *drmm_kmalloc_array(struct drm_device *dev,
+ size_t n, size_t size, gfp_t flags)
+{
+ size_t bytes;
+
+ if (unlikely(check_mul_overflow(n, size, &bytes)))
+ return NULL;
+
+ return drmm_kmalloc(dev, bytes, flags);
+}
+static inline void *drmm_kcalloc(struct drm_device *dev,
+ size_t n, size_t size, gfp_t flags)
+{
+ return drmm_kmalloc_array(dev, n, size, flags | __GFP_ZERO);
+}
char *drmm_kstrdup(struct drm_device *dev, const char *s, gfp_t gfp);
void drmm_kfree(struct drm_device *dev, void *data);