diff options
author | Sudip Mukherjee <sudipm.mukherjee@gmail.com> | 2015-07-13 12:02:28 (GMT) |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-07-27 17:30:47 (GMT) |
commit | 1037b2787b6df12f31b7051f7cdbb289f7972ee7 (patch) | |
tree | 8bde5d2469ea29dc36f00127a87d78dae2394615 /drivers/char/misc.c | |
parent | 344e62b36d3fa680ffbd35ee26b52f7bf4c1c4ec (diff) | |
download | linux-1037b2787b6df12f31b7051f7cdbb289f7972ee7.tar.xz |
char: misc: fix error path
Lets call remove_proc_entry() in the error path only if we have
successfully created "misc" in procfs.
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/char/misc.c')
-rw-r--r-- | drivers/char/misc.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/char/misc.c b/drivers/char/misc.c index 3b95795..c83ef96 100644 --- a/drivers/char/misc.c +++ b/drivers/char/misc.c @@ -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)) @@ -298,7 +299,8 @@ fail_printk: 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); |