@@ -515,6 +515,7 @@ static bool __init kfence_init_pool(void
{
unsigned long addr = (unsigned long)__kfence_pool;
struct page *pages;
+ char *p;
int i;
if (!__kfence_pool)
@@ -598,6 +599,16 @@ err:
* fails for the first page, and therefore expect addr==__kfence_pool in
* most failure cases.
*/
+ for (p = (char *)addr; p < __kfence_pool + KFENCE_POOL_SIZE; p += PAGE_SIZE) {
+ struct slab *slab = virt_to_slab(p);
+
+ if (!slab)
+ continue;
+#ifdef CONFIG_MEMCG
+ slab->memcg_data = 0;
+#endif
+ __folio_clear_slab(slab_folio(slab));
+ }
memblock_free_late(__pa(addr), KFENCE_POOL_SIZE - (addr - (unsigned long)__kfence_pool));
__kfence_pool = NULL;
return false;