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

Commit 22fed856 authored by Sunil Khatri's avatar Sunil Khatri Committed by Gerrit - the friendly Code Review server
Browse files

msm: kgsl: Fix the access to invalid pool



If a free page is not found in a particular pool, we
fall back to lower order pools. While doing so make
sure we dont do that when already in zero order pool.
For zero order(pool_idx = 0) pool, (pool_idx-1) value
becomes -1 that is invalid and compiler throws the error
that array subscript is below bounds.

This problem is exposed when we enable kernel config option
"CONFIG_ALLOC_BUFFERS_IN_4K_CHUNKS" which will force only
zero order pool and hence the index value calculation to -1.

Change-Id: I81e8a1e79cd974b7a13a9d23cb3d809464b6dcda
Signed-off-by: default avatarSunil Khatri <sunilkh@codeaurora.org>
parent e99d73e0
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -331,9 +331,10 @@ int kgsl_pool_alloc_page(int *page_size, struct page **pages,
		return -EINVAL;

	pool = _kgsl_get_pool_from_order(order);
	pool_idx = kgsl_pool_idx_lookup(order);
	if (pool == NULL)
		return -EINVAL;

	if (pool != NULL)
	pool_idx = kgsl_pool_idx_lookup(order);
	page = _kgsl_pool_get_page(pool);

	/* Allocate a new page if not allocated from pool */
@@ -341,7 +342,7 @@ int kgsl_pool_alloc_page(int *page_size, struct page **pages,
		gfp_t gfp_mask = kgsl_gfp_mask(order);

		/* Only allocate non-reserved memory for certain pools */
		if (!pool->allocation_allowed) {
		if (!pool->allocation_allowed && pool_idx > 0) {
			*page_size = PAGE_SIZE <<
					kgsl_pools[pool_idx-1].pool_order;
			*align = ilog2(*page_size);