mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
To: Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org,
	Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Subject: [PATCH 2/2] char: misc: fix error path
Date: Mon, 13 Jul 2015 17:32:28 +0530	[thread overview]
Message-ID: <1436788948-12543-2-git-send-email-sudipm.mukherjee@gmail.com> (raw)
In-Reply-To: <1436788948-12543-1-git-send-email-sudipm.mukherjee@gmail.com>

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


      reply	other threads:[~2015-07-13 12:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-13 12:02 [PATCH 1/2] char: misc: remove redundant ifdef Sudip Mukherjee
2015-07-13 12:02 ` Sudip Mukherjee [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1436788948-12543-2-git-send-email-sudipm.mukherjee@gmail.com \
    --to=sudipm.mukherjee@gmail.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®