Merge "msm: kgsl: Fix overflow in sharedmem cache range operation function"

This commit is contained in:
Linux Build Service Account 2016-11-14 21:54:05 -08:00 committed by Gerrit - the friendly Code Review server
commit 5587de21d7

View file

@ -574,12 +574,11 @@ int kgsl_cache_range_op(struct kgsl_memdesc *memdesc, uint64_t offset,
void *addr = (memdesc->hostptr) ?
memdesc->hostptr : (void *) memdesc->useraddr;
/* Make sure that size is non-zero */
if (!size)
if (size == 0 || size > UINT_MAX)
return -EINVAL;
/* Make sure that the offset + size isn't bigger than we can handle */
if ((offset + size) > ULONG_MAX)
/* Make sure that the offset + size does not overflow */
if ((offset + size < offset) || (offset + size < size))
return -ERANGE;
/* Make sure the offset + size do not overflow the address */