On Wed, 23 Mar 2022 11:48:24 +0800 xkernel.wang@xxxxxxxxxxx wrote: > From: Xiaoke Wang <xkernel.wang@xxxxxxxxxxx> > > To make the test more robust, there are the following changes: > 1. add a check for the return value of kmem_cache_alloc(). > 2. properly release the object `buf` on several error paths. > 3. release the objects of `used_objects` if we never hit `saved_ptr`. > 4. destroy the created cache by default. > > ... > > --- a/lib/test_meminit.c > +++ b/lib/test_meminit.c > @@ -300,13 +300,18 @@ static int __init do_kmem_cache_rcu_persistent(int size, int *total_failures) > c = kmem_cache_create("test_cache", size, size, SLAB_TYPESAFE_BY_RCU, > NULL); > buf = kmem_cache_alloc(c, GFP_KERNEL); > + if (!buf) > + goto out; OK, Normally we don't bother checking allocation success in __init code, but this test can run via modprobe, so I guess checking is the right thing to do.