[lkml]   [2002]   [Feb]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
SubjectFix for duplicate /proc entries

I think that I have found a problem with proc_dir_entry(). It seems to
allow multiple /proc entries to be created with the same name, without
returning a NULL pointer. I asked the folks on #kernelnewbies, and they
said that perhaps this is a feature. In either case, I believe that the
following patch fixes the issue by checking if a proc entry already exists
before creating it. This mirrors the behavior of remove_proc_entry, which
checks for the presense of a proc entry before deleting it.

Thank you
- Brent

--- linux/fs/proc/generic.bak Tue Feb 5 10:51:30 2002
+++ linux/fs/proc/generic.c Tue Feb 5 11:03:24 2002
@@ -418,6 +418,7 @@
mode_t mode,
nlink_t nlink)
+ struct proc_dir_entry **p;
struct proc_dir_entry *ent = NULL;
const char *fn = name;
int len;
@@ -429,6 +430,12 @@
goto out;
len = strlen(fn);

+ /* check for a duplication */
+ for (p = &(*parent)->subdir; *p; p=&(*p)->next ) {
+ if (proc_match(len, fn, *p))
+ goto out;
+ }
ent = kmalloc(sizeof(struct proc_dir_entry) + len + 1, GFP_KERNEL);
if (!ent) goto out;

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at
 \ /
  Last update: 2005-03-22 13:24    [W:0.091 / U:17.536 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site