Skip to content

Commit

Permalink
char: misc: fix error path
Browse files Browse the repository at this point in the history
Lets call remove_proc_entry() in the error path only if we have
successfully created "misc" in procfs.

Signed-off-by: Sudip Mukherjee <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
sudipm-mukherjee authored and gregkh committed Jul 27, 2015
1 parent 344e62b commit 1037b27
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/char/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,9 @@ static char *misc_devnode(struct device *dev, umode_t *mode)
static int __init misc_init(void)
{
int err;
struct proc_dir_entry *ret;

proc_create("misc", 0, NULL, &misc_proc_fops);
ret = proc_create("misc", 0, NULL, &misc_proc_fops);
misc_class = class_create(THIS_MODULE, "misc");
err = PTR_ERR(misc_class);
if (IS_ERR(misc_class))
Expand All @@ -298,7 +299,8 @@ static int __init misc_init(void)
printk("unable to get major %d for misc devices\n", MISC_MAJOR);
class_destroy(misc_class);
fail_remove:
remove_proc_entry("misc", NULL);
if (ret)
remove_proc_entry("misc", NULL);
return err;
}
subsys_initcall(misc_init);

0 comments on commit 1037b27

Please sign in to comment.