All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kirill Korotaev <dev@sw.ru>
To: linux-kernel@vger.kernel.org, Andrew Morton <akpm@osdl.org>,
	den@sw.ru, st@sw.ru
Subject: [PATCH] proc: fix of error path in proc_get_inode()
Date: Fri, 30 Sep 2005 15:37:05 +0400	[thread overview]
Message-ID: <433D2361.6000805@sw.ru> (raw)

[-- Attachment #1: Type: text/plain, Size: 590 bytes --]

This patch fixes incorrect error path in proc_get_inode(),
when module can't be get due to being unloaded.
When try_module_get() fails, this function puts de(!) and
still returns inode with non-getted de.

There are still unresolved known bugs in proc yet to be fixed:
- proc_dir_entry tree is managed without any serialization
- create_proc_entry() doesn't setup de->owner anyhow,
   so setting it later manually is inatomic.
- looks like almost all modules do not care whether
   it's de->owner is set...

Signed-Off-By: Denis Lunev <den@sw.ru>
Signed-Off-By: Kirill Korotaev <dev@sw.ru>

[-- Attachment #2: diff-proc-moduleget-20050930 --]
[-- Type: text/plain, Size: 955 bytes --]

--- ./fs/proc/inode.c.procino	2005-09-30 13:17:21.000000000 +0400
+++ ./fs/proc/inode.c	2005-09-30 13:17:55.000000000 +0400
@@ -205,10 +205,13 @@ struct inode *proc_get_inode(struct supe
 
 	WARN_ON(de && de->deleted);
 
+	if (de != NULL && !try_module_get(de->owner))
+		goto out_mod;
+
 	inode = iget(sb, ino);
 	if (!inode)
-		goto out_fail;
-	
+		goto out_ino;
+
 	PROC_I(inode)->pde = de;
 	if (de) {
 		if (de->mode) {
@@ -220,20 +223,20 @@ struct inode *proc_get_inode(struct supe
 			inode->i_size = de->size;
 		if (de->nlink)
 			inode->i_nlink = de->nlink;
-		if (!try_module_get(de->owner))
-			goto out_fail;
 		if (de->proc_iops)
 			inode->i_op = de->proc_iops;
 		if (de->proc_fops)
 			inode->i_fop = de->proc_fops;
 	}
 
-out:
 	return inode;
 
-out_fail:
+out_ino:
+	if (de != NULL)
+		module_put(de->owner);
+out_mod:
 	de_put(de);
-	goto out;
+	return NULL;
 }			
 
 int proc_fill_super(struct super_block *s, void *data, int silent)

                 reply	other threads:[~2005-09-30 11:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=433D2361.6000805@sw.ru \
    --to=dev@sw.ru \
    --cc=akpm@osdl.org \
    --cc=den@sw.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=st@sw.ru \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.