Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

zorro: use non-racy method for proc entries creation

Use proc_create()/proc_create_data() to make sure that ->proc_fops and ->data
be setup before gluing PDE to main tree.

Add correct ->owner to proc_fops to fix reading/module unloading race.

Signed-off-by: Denis V. Lunev <den@openvz.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Denis V. Lunev and committed by
Linus Torvalds
659f865e 7bf4e6d3

+4 -3
+4 -3
drivers/zorro/proc.c
··· 77 77 } 78 78 79 79 static const struct file_operations proc_bus_zorro_operations = { 80 + .owner = THIS_MODULE, 80 81 .llseek = proc_bus_zorro_lseek, 81 82 .read = proc_bus_zorro_read, 82 83 }; ··· 137 136 char name[4]; 138 137 139 138 sprintf(name, "%02x", slot); 140 - entry = create_proc_entry(name, 0, proc_bus_zorro_dir); 139 + entry = proc_create_data(name, 0, proc_bus_zorro_dir, 140 + &proc_bus_zorro_operations, 141 + &zorro_autocon[slot]); 141 142 if (!entry) 142 143 return -ENOMEM; 143 - entry->proc_fops = &proc_bus_zorro_operations; 144 - entry->data = &zorro_autocon[slot]; 145 144 entry->size = sizeof(struct zorro_dev); 146 145 return 0; 147 146 }