lkml.org 
[lkml]   [2015]   [Jul]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/2] char: misc: fix error path
Date
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>
---
drivers/char/misc.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index 3b95795..acedbaf 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);
--
1.8.1.2


\
 
 \ /
  Last update: 2015-07-13 14:21    [W:0.031 / U:0.244 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site