proc: kmalloc struct pde_opener
authorAlexey Dobriyan <adobriyan@gmail.com>
Tue, 13 Dec 2016 00:45:20 +0000 (16:45 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 13 Dec 2016 02:55:09 +0000 (18:55 -0800)
kzalloc is too much, half of the fields will be reinitialized anyway.

If proc file doesn't have ->release hook (some still do not), clearing
is unnecessary because it will be freed immediately.

Link: http://lkml.kernel.org/r/20161029155747.GC1246@avx2
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/proc/inode.c

index f623a3c..57f548e 100644 (file)
@@ -321,7 +321,7 @@ static int proc_reg_open(struct inode *inode, struct file *file)
         * by hand in remove_proc_entry(). For this, save opener's credentials
         * for later.
         */
-       pdeo = kzalloc(sizeof(struct pde_opener), GFP_KERNEL);
+       pdeo = kmalloc(sizeof(struct pde_opener), GFP_KERNEL);
        if (!pdeo)
                return -ENOMEM;
 
@@ -338,6 +338,8 @@ static int proc_reg_open(struct inode *inode, struct file *file)
        if (rv == 0 && release) {
                /* To know what to release. */
                pdeo->file = file;
+               pdeo->closing = false;
+               pdeo->c = NULL;
                /* Strictly for "too late" ->release in proc_reg_release(). */
                spin_lock(&pde->pde_unload_lock);
                list_add(&pdeo->lh, &pde->pde_openers);