Skip to content

Commit

Permalink
zorro: use non-racy method for proc entries creation
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Geert Uytterhoeven <[email protected]>
Cc: Alexey Dobriyan <[email protected]>
Cc: "Eric W. Biederman" <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
dlunev authored and torvalds committed Apr 29, 2008

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 7bf4e6d commit 659f865
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions drivers/zorro/proc.c
Original file line number Diff line number Diff line change
@@ -77,6 +77,7 @@ proc_bus_zorro_read(struct file *file, char __user *buf, size_t nbytes, loff_t *
}

static const struct file_operations proc_bus_zorro_operations = {
.owner = THIS_MODULE,
.llseek = proc_bus_zorro_lseek,
.read = proc_bus_zorro_read,
};
@@ -136,11 +137,11 @@ static int __init zorro_proc_attach_device(u_int slot)
char name[4];

sprintf(name, "%02x", slot);
entry = create_proc_entry(name, 0, proc_bus_zorro_dir);
entry = proc_create_data(name, 0, proc_bus_zorro_dir,
&proc_bus_zorro_operations,
&zorro_autocon[slot]);
if (!entry)
return -ENOMEM;
entry->proc_fops = &proc_bus_zorro_operations;
entry->data = &zorro_autocon[slot];
entry->size = sizeof(struct zorro_dev);
return 0;
}

0 comments on commit 659f865

Please sign in to comment.