Skip to content

Commit f6d0c3d

Browse files
committed
posix-timers: Remove SLAB_PANIC from kmem cache
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 <[email protected]> Reviewed-by: Frederic Weisbecker <[email protected]> Link: https://lore.kernel.org/all/[email protected]
1 parent 4c5cd05 commit f6d0c3d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

kernel/time/posix-timers.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,8 @@ static int posix_get_hrtimer_res(clockid_t which_clock, struct timespec64 *tp)
243243

244244
static __init int init_posix_timers(void)
245245
{
246-
posix_timers_cache = kmem_cache_create("posix_timers_cache",
247-
sizeof(struct k_itimer), 0,
248-
SLAB_PANIC | SLAB_ACCOUNT, NULL);
246+
posix_timers_cache = kmem_cache_create("posix_timers_cache", sizeof(struct k_itimer), 0,
247+
SLAB_ACCOUNT, NULL);
249248
return 0;
250249
}
251250
__initcall(init_posix_timers);
@@ -371,8 +370,12 @@ static struct pid *good_sigevent(sigevent_t * event)
371370

372371
static struct k_itimer *alloc_posix_timer(void)
373372
{
374-
struct k_itimer *tmr = kmem_cache_zalloc(posix_timers_cache, GFP_KERNEL);
373+
struct k_itimer *tmr;
375374

375+
if (unlikely(!posix_timers_cache))
376+
return NULL;
377+
378+
tmr = kmem_cache_zalloc(posix_timers_cache, GFP_KERNEL);
376379
if (!tmr)
377380
return tmr;
378381

0 commit comments

Comments
 (0)