summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2003-07-18 06:00:06 -0700
committerLinus Torvalds <torvalds@home.osdl.org>2003-07-18 06:00:06 -0700
commit2c420d4a174456d57626fc09f752cb7a83752e08 (patch)
tree8de026683a22e9b8bd1cc051b141f21d3da912cc
parenta26698b43c3560d0bf269d66c6568f5352b2384b (diff)
[PATCH] Use before initialisation in devfs_mk_cdev()
As noted by Gergely Nagy: "devfs_mk_cdev() first checks the mode passed to it, and if it thinks it is not a char device, it prints a warning and aborts. Now, this printing involves the local variable `buf' (char buf[64]), which is not initialised at that point." The same problem also affects devfs_mk_bdev. Fixed thus.
-rw-r--r--fs/devfs/base.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/fs/devfs/base.c b/fs/devfs/base.c
index 54a3e5a9dc49..060f20ef11f1 100644
--- a/fs/devfs/base.c
+++ b/fs/devfs/base.c
@@ -1445,12 +1445,6 @@ int devfs_mk_bdev(dev_t dev, umode_t mode, const char *fmt, ...)
va_list args;
int error, n;
- if (!S_ISBLK(mode)) {
- printk(KERN_WARNING "%s: invalide mode (%u) for %s\n",
- __FUNCTION__, mode, buf);
- return -EINVAL;
- }
-
va_start(args, fmt);
n = vsnprintf(buf, 64, fmt, args);
if (n >= 64 || !buf[0]) {
@@ -1458,6 +1452,12 @@ int devfs_mk_bdev(dev_t dev, umode_t mode, const char *fmt, ...)
__FUNCTION__);
return -EINVAL;
}
+
+ if (!S_ISBLK(mode)) {
+ printk(KERN_WARNING "%s: invalide mode (%u) for %s\n",
+ __FUNCTION__, mode, buf);
+ return -EINVAL;
+ }
de = _devfs_prepare_leaf(&dir, buf, mode);
if (!de) {
@@ -1491,12 +1491,6 @@ int devfs_mk_cdev(dev_t dev, umode_t mode, const char *fmt, ...)
va_list args;
int error, n;
- if (!S_ISCHR(mode)) {
- printk(KERN_WARNING "%s: invalide mode (%u) for %s\n",
- __FUNCTION__, mode, buf);
- return -EINVAL;
- }
-
va_start(args, fmt);
n = vsnprintf(buf, 64, fmt, args);
if (n >= 64 || !buf[0]) {
@@ -1505,6 +1499,12 @@ int devfs_mk_cdev(dev_t dev, umode_t mode, const char *fmt, ...)
return -EINVAL;
}
+ if (!S_ISCHR(mode)) {
+ printk(KERN_WARNING "%s: invalide mode (%u) for %s\n",
+ __FUNCTION__, mode, buf);
+ return -EINVAL;
+ }
+
de = _devfs_prepare_leaf(&dir, buf, mode);
if (!de) {
printk(KERN_WARNING "%s: could not prepare leaf for %s\n",