From 332eb97e8c8ce23a6222a4af9356c0fa0e5f8341 Mon Sep 17 00:00:00 2001 From: Xi Wang Date: Thu, 31 May 2012 16:26:04 -0700 Subject: [PATCH] --- yaml --- r: 309708 b: refs/heads/master c: a3860c1c5dd1137db23d7786d284939c5761d517 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/fs/ceph/snap.c | 2 +- trunk/include/drm/drm_mem_util.h | 4 ++-- trunk/include/linux/kernel.h | 1 + trunk/include/linux/slab.h | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/[refs] b/[refs] index 45d0c9761296..5934f9aae44a 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 15837294d4ce717f69942f7366e99d4d1d3d9923 +refs/heads/master: a3860c1c5dd1137db23d7786d284939c5761d517 diff --git a/trunk/fs/ceph/snap.c b/trunk/fs/ceph/snap.c index f04c0961f993..e5206fc76562 100644 --- a/trunk/fs/ceph/snap.c +++ b/trunk/fs/ceph/snap.c @@ -331,7 +331,7 @@ static int build_snap_context(struct ceph_snap_realm *realm) /* alloc new snap context */ err = -ENOMEM; - if (num > (ULONG_MAX - sizeof(*snapc)) / sizeof(u64)) + if (num > (SIZE_MAX - sizeof(*snapc)) / sizeof(u64)) goto fail; snapc = kzalloc(sizeof(*snapc) + num*sizeof(u64), GFP_NOFS); if (!snapc) diff --git a/trunk/include/drm/drm_mem_util.h b/trunk/include/drm/drm_mem_util.h index 6bd325fedc87..19a240446fca 100644 --- a/trunk/include/drm/drm_mem_util.h +++ b/trunk/include/drm/drm_mem_util.h @@ -31,7 +31,7 @@ static __inline__ void *drm_calloc_large(size_t nmemb, size_t size) { - if (size != 0 && nmemb > ULONG_MAX / size) + if (size != 0 && nmemb > SIZE_MAX / size) return NULL; if (size * nmemb <= PAGE_SIZE) @@ -44,7 +44,7 @@ static __inline__ void *drm_calloc_large(size_t nmemb, size_t size) /* Modeled after cairo's malloc_ab, it's like calloc but without the zeroing. */ static __inline__ void *drm_malloc_ab(size_t nmemb, size_t size) { - if (size != 0 && nmemb > ULONG_MAX / size) + if (size != 0 && nmemb > SIZE_MAX / size) return NULL; if (size * nmemb <= PAGE_SIZE) diff --git a/trunk/include/linux/kernel.h b/trunk/include/linux/kernel.h index ec55a3c8ba77..e07f5e0c5df4 100644 --- a/trunk/include/linux/kernel.h +++ b/trunk/include/linux/kernel.h @@ -35,6 +35,7 @@ #define LLONG_MAX ((long long)(~0ULL>>1)) #define LLONG_MIN (-LLONG_MAX - 1) #define ULLONG_MAX (~0ULL) +#define SIZE_MAX (~(size_t)0) #define STACK_MAGIC 0xdeadbeef diff --git a/trunk/include/linux/slab.h b/trunk/include/linux/slab.h index a595dce6b0c7..67d5d94b783a 100644 --- a/trunk/include/linux/slab.h +++ b/trunk/include/linux/slab.h @@ -242,7 +242,7 @@ size_t ksize(const void *); */ static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags) { - if (size != 0 && n > ULONG_MAX / size) + if (size != 0 && n > SIZE_MAX / size) return NULL; return __kmalloc(n * size, flags); }