Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9d6495a8 authored by Jordan Crouse's avatar Jordan Crouse
Browse files

msm: kgsl: Protect against a potential overflow in kgsl_sg_alloc



Avoid allocating a scatterlist so large that it overflows the size
passed to the memory allocators.

CRs-fixed: 564448
Change-Id: Ic0dedbad2ab421ddec8f3be38d61c9bdf9ae5bd4
Signed-off-by: default avatarJordan Crouse <jcrouse@codeaurora.org>
parent 4813d157
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -137,6 +137,9 @@ kgsl_sharedmem_map_vma(struct vm_area_struct *vma,

static inline void *kgsl_sg_alloc(unsigned int sglen)
{
	if (sglen >= ULONG_MAX / sizeof(struct scatterlist))
		return NULL;

	if ((sglen * sizeof(struct scatterlist)) <  PAGE_SIZE)
		return kzalloc(sglen * sizeof(struct scatterlist), GFP_KERNEL);
	else