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

Commit 68b276e2 authored by Jordan Crouse's avatar Jordan Crouse Committed by Shubhraprakash Das
Browse files

msm: kgsl: Correctly handle page allocation failure



If we fail on the first page allocation iteration in
_kgsl_sharedmem_page_alloc then sglen will be 0. Do not blindly
set sg_mark_end() on sg[sglen - 1] without verifying that we
allocated at least one block. We can also skip iterating the
sglist when freeing if sglen is 0.

CRs-Fixed: 771199
Change-Id: Ic0dedbad22c88c1f9efccffddaf266a9a9af4b08
Signed-off-by: default avatarJordan Crouse <jcrouse@codeaurora.org>
parent 845c96e6
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -402,7 +402,7 @@ static void kgsl_page_alloc_free(struct kgsl_memdesc *memdesc)
	/* we certainly do not expect the hostptr to still be mapped */
	BUG_ON(memdesc->hostptr);

	if (memdesc->sg)
	if (sglen && memdesc->sg)
		for_each_sg(memdesc->sg, sg, sglen, i)
			__free_pages(sg_page(sg), get_order(sg->length));
}
@@ -691,6 +691,8 @@ _kgsl_sharedmem_page_alloc(struct kgsl_memdesc *memdesc,
			 */
			memdesc->sglen = sglen;
			memdesc->size = (size - len);

			if (sglen > 0)
				sg_mark_end(&memdesc->sg[sglen - 1]);

			KGSL_CORE_ERR(