Skip to content

Commit b0bd316

Browse files
Kamal AgrawalmikeNG
authored andcommitted
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: Kamal Agrawal <quic_kamaagra@quicinc.com>
1 parent 43add1c commit b0bd316

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

drivers/gpu/msm/kgsl_pool.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
2+
* Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
23
*
34
* This program is free software; you can redistribute it and/or modify
45
* it under the terms of the GNU General Public License version 2 and
@@ -83,6 +84,15 @@ _kgsl_pool_zero_page(struct page *p, unsigned int pool_order)
8384
static void
8485
_kgsl_pool_add_page(struct kgsl_page_pool *pool, struct page *p)
8586
{
87+
/*
88+
* Sanity check to make sure we don't re-pool a page that
89+
* somebody else has a reference to.
90+
*/
91+
if (WARN_ON_ONCE(unlikely(page_count(p) > 1))) {
92+
__free_pages(p, pool->pool_order);
93+
return;
94+
}
95+
8696
_kgsl_pool_zero_page(p, pool->pool_order);
8797

8898
spin_lock(&pool->list_lock);

0 commit comments

Comments
 (0)