summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarshitha Sai Neelati <quic_hsaineel@quicinc.com>2023-02-16 12:43:32 +0530
committerPankaj Gupta <quic_gpankaj@quicinc.com>2023-02-28 15:10:32 +0530
commite2f506a3fadf7310df96a7cd6476fb75459f91d7 (patch)
tree90324d73ab3671adc08701216e8d928269eae5e3
parent67887f6ac3f11fd5ee1639e18d854e6071e58c51 (diff)
msm: kgsl: Make sure that pool pages don't have any extra references
Before putting a page back in the pool be sure that it doesn't have any additional references that would be a signal that somebody else is looking at the page and that it would be a bad idea to keep it around and run the risk of accidentally handing it to a different process. Change-Id: Ic0dedbad0cf2ffb34b76ad23e393c5a911114b82 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Harshitha Sai Neelati <quic_hsaineel@quicinc.com>
-rw-r--r--drivers/gpu/msm/kgsl_pool.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/gpu/msm/kgsl_pool.c b/drivers/gpu/msm/kgsl_pool.c
index 4a9997b02155..52453e5a0791 100644
--- a/drivers/gpu/msm/kgsl_pool.c
+++ b/drivers/gpu/msm/kgsl_pool.c
@@ -1,4 +1,5 @@
/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -78,6 +79,15 @@ _kgsl_pool_zero_page(struct page *p)
static void
_kgsl_pool_add_page(struct kgsl_page_pool *pool, struct page *p)
{
+ /*
+ * Sanity check to make sure we don't re-pool a page that
+ * somebody else has a reference to.
+ */
+ if (WARN_ON_ONCE(unlikely(page_count(p) > 1))) {
+ __free_pages(p, pool->pool_order);
+ return;
+ }
+
spin_lock(&pool->list_lock);
list_add_tail(&p->lru, &pool->page_list);
pool->page_count++;