lkml.org 
[lkml]   [2000]   [Aug]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] fs/proc/generic.c: check proc_register result
Linus,

proc_register can fail and its result is not being checked, I've also
noticed that at one place (the first hunk in the patch below) it returns a
kfreed pointer on failure.

- Arnaldo

--- linux-2.4.0-test8-pre1/fs/proc/generic.c Thu Aug 24 07:40:11 2000
+++ linux-2.4.0-test8-pre1.acme/fs/proc/generic.c Tue Aug 29 21:27:10 2000
@@ -427,16 +427,17 @@
ent->nlink = 1;
ent->mode = S_IFLNK|S_IRUGO|S_IWUGO|S_IXUGO;
ent->data = kmalloc((ent->size=strlen(dest))+1, GFP_KERNEL);
- if (!ent->data) {
- kfree(ent);
- goto out;
- }
+ if (!ent->data)
+ goto cleanup_ent;
strcpy((char*)ent->data,dest);

- proc_register(parent, ent);
-
+ if (proc_register(parent, ent))
+ goto cleanup_data;
out:
return ent;
+cleanup_data: kfree(ent->data);
+cleanup_ent: kfree(ent);
+ return NULL;
}

struct proc_dir_entry *proc_mknod(const char *name, mode_t mode,
@@ -461,8 +462,10 @@
ent->mode = mode;
ent->rdev = rdev;

- proc_register(parent, ent);
-
+ if (proc_register(parent, ent)) {
+ kfree(ent);
+ return NULL;
+ }
out:
return ent;
}
@@ -489,8 +492,10 @@
ent->nlink = 2;
ent->mode = S_IFDIR | S_IRUGO | S_IXUGO;

- proc_register(parent, ent);
-
+ if (proc_register(parent, ent)) {
+ kfree(ent);
+ return NULL;
+ }
out:
return ent;
}
@@ -529,8 +534,10 @@
}
ent->mode = mode;

- proc_register(parent, ent);
-
+ if (proc_register(parent, ent)) {
+ kfree(ent);
+ return NULL;
+ }
out:
return ent;
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 12:38    [W:0.036 / U:0.208 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site