linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] procfs: Fix error handling of proc_register()
@ 2014-10-16 20:46 Debabrata Banerjee
  2014-10-22 22:40 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Debabrata Banerjee @ 2014-10-16 20:46 UTC (permalink / raw)
  To: kdevcore; +Cc: Debabrata Banerjee, linux-fsdevel

	I don't see why this should print warnings at all instead of properly
	unrolling allocations and returning an appropriate error. It's actually
	leaking resources currently.

to: Alexander Viro <viro@zeniv.linux.org.uk>
to: linux-kernel@vger.kernel.org
cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Debabrata Banerjee <dbanerje@akamai.com>
---
 fs/proc/generic.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index 317b726..89b20cc 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -304,6 +304,7 @@ static int proc_register(struct proc_dir_entry * dir, struct proc_dir_entry * dp
 		dp->proc_iops = &proc_file_inode_operations;
 	} else {
 		WARN_ON(1);
+		proc_free_inum(dp->low_ino);
 		return -EINVAL;
 	}
 
@@ -311,9 +312,13 @@ static int proc_register(struct proc_dir_entry * dir, struct proc_dir_entry * dp
 
 	for (tmp = dir->subdir; tmp; tmp = tmp->next)
 		if (strcmp(tmp->name, dp->name) == 0) {
-			WARN(1, "proc_dir_entry '%s/%s' already registered\n",
-				dir->name, dp->name);
-			break;
+			spin_unlock(&proc_subdir_lock);
+
+			if (S_ISDIR(dp->mode))
+				dir->nlink--;
+
+			proc_free_inum(dp->low_ino);
+			return -EEXIST;
 		}
 
 	dp->next = dir->subdir;
-- 
2.1.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-10-23  7:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-16 20:46 [PATCH] procfs: Fix error handling of proc_register() Debabrata Banerjee
2014-10-22 22:40 ` Andrew Morton
2014-10-23  7:23   ` Nicolas Dichtel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).