diff options
Diffstat (limited to 'include/drm')
-rw-r--r-- | include/drm/drmP.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/include/drm/drmP.h b/include/drm/drmP.h index b0b36838ab11..1b807d0f6cdb 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h | |||
@@ -1545,14 +1545,27 @@ static __inline__ void drm_core_dropmap(struct drm_local_map *map) | |||
1545 | 1545 | ||
1546 | static __inline__ void *drm_calloc_large(size_t nmemb, size_t size) | 1546 | static __inline__ void *drm_calloc_large(size_t nmemb, size_t size) |
1547 | { | 1547 | { |
1548 | if (size != 0 && nmemb > ULONG_MAX / size) | ||
1549 | return NULL; | ||
1550 | |||
1548 | if (size * nmemb <= PAGE_SIZE) | 1551 | if (size * nmemb <= PAGE_SIZE) |
1549 | return kcalloc(nmemb, size, GFP_KERNEL); | 1552 | return kcalloc(nmemb, size, GFP_KERNEL); |
1550 | 1553 | ||
1554 | return __vmalloc(size * nmemb, | ||
1555 | GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL); | ||
1556 | } | ||
1557 | |||
1558 | /* Modeled after cairo's malloc_ab, it's like calloc but without the zeroing. */ | ||
1559 | static __inline__ void *drm_malloc_ab(size_t nmemb, size_t size) | ||
1560 | { | ||
1551 | if (size != 0 && nmemb > ULONG_MAX / size) | 1561 | if (size != 0 && nmemb > ULONG_MAX / size) |
1552 | return NULL; | 1562 | return NULL; |
1553 | 1563 | ||
1564 | if (size * nmemb <= PAGE_SIZE) | ||
1565 | return kmalloc(nmemb * size, GFP_KERNEL); | ||
1566 | |||
1554 | return __vmalloc(size * nmemb, | 1567 | return __vmalloc(size * nmemb, |
1555 | GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL); | 1568 | GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL); |
1556 | } | 1569 | } |
1557 | 1570 | ||
1558 | static __inline void drm_free_large(void *ptr) | 1571 | static __inline void drm_free_large(void *ptr) |