linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/shrinker: Fix refcount leak in shrink_slab_memcg()
@ 2026-02-03  7:37 Altan Hacigumus
  2026-02-03  8:17 ` Qi Zheng
  2026-02-04  3:35 ` [PATCH v2] " Altan Hacigumus
  0 siblings, 2 replies; 7+ messages in thread
From: Altan Hacigumus @ 2026-02-03  7:37 UTC (permalink / raw)
  To: akpm, david
  Cc: ahacigu.linux, zhengqi.arch, roman.gushchin, muchun.song,
	linux-mm, linux-kernel

When kmem is disabled for memcg, slab-backed shrinkers are skipped.
However, shrink_slab_memcg() doesn't drop the reference acquired via
shrinker_try_get() before continuing.

Add the missing shrinker_put().

Fixes: 50d09da8e119 ("mm: shrinker: make memcg slab shrink lockless")

Signed-off-by: Altan Hacigumus <ahacigu.linux@gmail.com>
---
 mm/shrinker.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/mm/shrinker.c b/mm/shrinker.c
index 4a93fd433689..d0be120488b4 100644
--- a/mm/shrinker.c
+++ b/mm/shrinker.c
@@ -544,8 +544,10 @@ static unsigned long shrink_slab_memcg(gfp_t gfp_mask, int nid,
 
 			/* Call non-slab shrinkers even though kmem is disabled */
 			if (!memcg_kmem_online() &&
-			    !(shrinker->flags & SHRINKER_NONSLAB))
+			    !(shrinker->flags & SHRINKER_NONSLAB)) {
+				shrinker_put(shrinker);
 				continue;
+			}
 
 			ret = do_shrink_slab(&sc, shrinker, priority);
 			if (ret == SHRINK_EMPTY) {
-- 
2.43.0



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-02-04  4:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-03  7:37 [PATCH] mm/shrinker: Fix refcount leak in shrink_slab_memcg() Altan Hacigumus
2026-02-03  8:17 ` Qi Zheng
2026-02-03  8:43   ` Altan Hacigumus
2026-02-03  9:10   ` Altan Hacigumus
2026-02-04  3:35 ` [PATCH v2] " Altan Hacigumus
2026-02-04  3:55   ` Qi Zheng
2026-02-04  4:00   ` Muchun Song

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox