Messages in this thread | | | Date | Tue, 12 Jun 2018 08:09:38 +0300 | From | Alexey Dobriyan <> | Subject | Re: [PATCH] proc: add error handling for kmem_cache_create |
| |
On Tue, Jun 12, 2018 at 12:23:52PM +0800, Zhouyang Jia wrote: > When kmem_cache_create fails, the lack of error-handling code may > cause unexpected results. > > This patch adds error-handling code after calling kmem_cache_create.
> pde_opener_cache = > kmem_cache_create("pde_opener", sizeof(struct pde_opener), 0, > SLAB_ACCOUNT|SLAB_PANIC, NULL); > + if (!proc_inode_cachep || !pde_opener_cache) > + return -ENOMEM;
SLAB_PANIC was added to not worry about error handling.
| |