check errors in early init
cover check errors in early init
Do the diligence of checking if any of the (inicall) io_uring_init() fail and if so return an error.
Pavel Begunkov (3):
io_uring: propagate req cache creation errors
io_uring: propagate io_buffer creation errors
io_uring: check for iowq alloc_workqueue errors
io_uring/io_uring.c | 7 +++++++ 1 file changed, 7 insertions(+)
Signature · 1 line
2.47.1
PATCH 1/3 io_uring: propagate req cache creation errors
It's very unlikely, but in theory cache creation can fail during initcall, so don't forget to return errors back if something goes wrong.
--- io_uring/io_uring.c | 3 +++ 1 file changed, 3 insertions(+)
io_uring/io_uring.c +3 -0
@@ -3916,6 +3916,9 @@ static int __init io_uring_init(void) req_cachep =kmem_cache_create ("io_kiocb" ,sizeof (struct io_kiocb ), &kmem_args,SLAB_HWCACHE_ALIGN |SLAB_PANIC |SLAB_ACCOUNT |SLAB_TYPESAFE_BY_RCU ); +if (!req_cachep) +return -ENOMEM ; + io_buf_cachep =KMEM_CACHE (io_buffer,SLAB_HWCACHE_ALIGN |SLAB_PANIC |SLAB_ACCOUNT );
Signature · 1 line
2.47.1
PATCH 2/3 io_uring: propagate io_buffer creation errors
In reply to Pavel BegunkovIt's very unlikely, but in theory cache creation can fail during initcall, so don't forget to return errors back if something goes wrong.
--- io_uring/io_uring.c | 2 ++ 1 file changed, 2 insertions(+)
io_uring/io_uring.c +2 -0
@@ -3921,6 +3921,8 @@ static int __init io_uring_init(void) io_buf_cachep =KMEM_CACHE (io_buffer,SLAB_HWCACHE_ALIGN |SLAB_PANIC |SLAB_ACCOUNT ); +if (!io_buf_cachep) +return -ENOMEM ; iou_wq =alloc_workqueue ("iou_exit" ,WQ_UNBOUND ,64 );
Signature · 1 line
2.47.1
PATCH 3/3 io_uring: check for iowq alloc_workqueue errors
In reply to Pavel Begunkovalloc_workqueue() can fail, check the result and return an error back from io_uring_init() if needed.
--- io_uring/io_uring.c | 2 ++ 1 file changed, 2 insertions(+)
io_uring/io_uring.c +2 -0
@@ -3925,6 +3925,8 @@ static int __init io_uring_init(void)return -ENOMEM ; iou_wq =alloc_workqueue ("iou_exit" ,WQ_UNBOUND ,64 ); +if (!iou_wq) +return -ENOMEM ;#ifdef CONFIG_SYSCTL register_sysctl_init ("kernel" , kernel_io_uring_disabled_table);
Signature · 1 line
2.47.1
Jens Axboe
maintainerRe: [PATCH 1/3] io_uring: propagate req cache creation errors
In reply to Pavel BegunkovQuoted 2 lines · Pavel Begunkov
It's very unlikely, but in theory cache creation can fail during initcall, so don't forget to return errors back if something goes wrong.
This is why SLAB_PANIC is used, it'll panic if this fails. That's commonly used for setup/init time kind of setups, where we never expect any failure to occur. Hence this can never return NULL.
Signature · 1 line
Jens Axboe
Re: [PATCH 1/3] io_uring: propagate req cache creation errors
Quoted 7 lines · Jens Axboe
Quoted 2 lines · Pavel Begunkov
It's very unlikely, but in theory cache creation can fail during initcall, so don't forget to return errors back if something goes wrong.
This is why
SLAB_PANICis used, it'll panic if this fails. That's commonly used for setup/init time kind of setups, where we never expect any failure to occur. Hence this can never return NULL.
Yeah, missed it, thanks
Signature · 1 line
Pavel Begunkov