]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Fixed cold page cache leak
authorMaria Matejka <mq@ucw.cz>
Wed, 3 May 2023 16:59:52 +0000 (18:59 +0200)
committerMaria Matejka <mq@ucw.cz>
Sat, 6 May 2023 08:50:31 +0000 (10:50 +0200)
The empty_pages pointer wasn't being propagated into the ->next pointer
when more empty_pages were to be stored

sysdep/unix/alloc.c

index 2205f152793e45715de570d743425aafb35c8f26..891a0e69d4da002debe6a4b00399046fe563366f 100644 (file)
@@ -282,10 +282,13 @@ page_cleanup(void *_ UNUSED)
     if (!empty_pages || (empty_pages->pos == EP_POS_MAX))
     {
       /* There is either no pointer block or the last block is full. We use this block as a pointer block. */
-      empty_pages = (struct empty_pages *) fp;
-      UNPROTECT_PAGE(empty_pages);
-      *empty_pages = (struct empty_pages) {};
-      PROTECT_PAGE(empty_pages);
+      struct empty_pages *ep = (struct empty_pages *) fp;
+      UNPROTECT_PAGE(ep);
+      *ep = (struct empty_pages) {
+       .next = empty_pages,
+      };
+      PROTECT_PAGE(ep);
+      empty_pages = ep;
     }
     else
     {