]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
mmap-cache: LIST_REMOVE() *after* w->unused_prev
authorVito Caputo <vcaputo@pengaru.com>
Thu, 25 Nov 2021 15:05:06 +0000 (07:05 -0800)
committerLennart Poettering <lennart@poettering.net>
Thu, 25 Nov 2021 20:39:38 +0000 (21:39 +0100)
The LIST_REMOVE() macro always assigns NULL to w->unused_prev,
meaning every time this window was in last_unused, the remainder
of the unused list was lost to the ether.

Turns out there's been a memory leak in journald after all, this
code has been there since at least 2013...

src/libsystemd/sd-journal/mmap-cache.c

index cc02d8c76c4417274d7929f4ca4a0f5d445c269b..f2f80dfbb22a691190addb09d50068c0982b6689 100644 (file)
@@ -224,9 +224,9 @@ static void context_attach_window(Context *c, Window *w) {
 
         if (w->in_unused) {
                 /* Used again? */
-                LIST_REMOVE(unused, c->cache->unused, w);
                 if (c->cache->last_unused == w)
                         c->cache->last_unused = w->unused_prev;
+                LIST_REMOVE(unused, c->cache->unused, w);
 
                 w->in_unused = false;
         }