]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
posix-timers: Remove SLAB_PANIC from kmem cache
authorThomas Gleixner <tglx@linutronix.de>
Sat, 8 Mar 2025 16:48:26 +0000 (17:48 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 13 Mar 2025 11:07:16 +0000 (12:07 +0100)
There is no need to panic when the posix-timer kmem_cache can't be
created. timer_create() will fail with -ENOMEM and that's it.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
Link: https://lore.kernel.org/all/20250308155623.829215801@linutronix.de
kernel/time/posix-timers.c

index 5591b1589985ceb7eb7c73481eb6c044e0ad76e5..b7bf8633cf38ba025365b883a0d0b5568f1380a0 100644 (file)
@@ -243,9 +243,8 @@ static int posix_get_hrtimer_res(clockid_t which_clock, struct timespec64 *tp)
 
 static __init int init_posix_timers(void)
 {
-       posix_timers_cache = kmem_cache_create("posix_timers_cache",
-                                       sizeof(struct k_itimer), 0,
-                                       SLAB_PANIC | SLAB_ACCOUNT, NULL);
+       posix_timers_cache = kmem_cache_create("posix_timers_cache", sizeof(struct k_itimer), 0,
+                                              SLAB_ACCOUNT, NULL);
        return 0;
 }
 __initcall(init_posix_timers);
@@ -371,8 +370,12 @@ static struct pid *good_sigevent(sigevent_t * event)
 
 static struct k_itimer *alloc_posix_timer(void)
 {
-       struct k_itimer *tmr = kmem_cache_zalloc(posix_timers_cache, GFP_KERNEL);
+       struct k_itimer *tmr;
 
+       if (unlikely(!posix_timers_cache))
+               return NULL;
+
+       tmr = kmem_cache_zalloc(posix_timers_cache, GFP_KERNEL);
        if (!tmr)
                return tmr;