Fix misuses of bdevname()
authorJean Delvare <khali@linux-fr.org>
Mon, 12 May 2008 21:02:33 +0000 (14:02 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 13 May 2008 15:02:26 +0000 (08:02 -0700)
bdevname() fills the buffer that it is given as a parameter, so calling
strcpy() or snprintf() on the returned value is redundant (and probably not
guaranteed to work - I don't think strcpy and snprintf support overlapping
buffers.)

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Stephen Tweedie <sct@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
block/blktrace.c
block/compat_ioctl.c
fs/ext4/mballoc.c
fs/jbd2/journal.c

index 568588cd16b22d546771e18fb4e34f9be4811afe..b2cbb4e5d7673c7a49ea557d962022f7ba3594f9 100644 (file)
@@ -476,7 +476,7 @@ int blk_trace_ioctl(struct block_device *bdev, unsigned cmd, char __user *arg)
 
        switch (cmd) {
        case BLKTRACESETUP:
-               strcpy(b, bdevname(bdev, b));
+               bdevname(bdev, b);
                ret = blk_trace_setup(q, b, bdev->bd_dev, arg);
                break;
        case BLKTRACESTART:
index c70d0b6f666fff96feb69f97fe9ed30e2990fa19..c23177e4623f1ba73804479460742dd63339556a 100644 (file)
@@ -555,7 +555,7 @@ static int compat_blk_trace_setup(struct block_device *bdev, char __user *arg)
        if (copy_from_user(&cbuts, arg, sizeof(cbuts)))
                return -EFAULT;
 
-       strcpy(b, bdevname(bdev, b));
+       bdevname(bdev, b);
 
        buts = (struct blk_user_trace_setup) {
                .act_mask = cbuts.act_mask,
index fbec2ef93797efb9bf6ac16f2a9465fc198dc018..b128bdc0f55cccf067dca2e1aecb991ee9a120c3 100644 (file)
@@ -2639,8 +2639,7 @@ static int ext4_mb_init_per_dev_proc(struct super_block *sb)
        struct proc_dir_entry *proc;
        char devname[64];
 
-       snprintf(devname, sizeof(devname) - 1, "%s",
-               bdevname(sb->s_bdev, devname));
+       bdevname(sb->s_bdev, devname);
        sbi->s_mb_proc = proc_mkdir(devname, proc_root_ext4);
 
        MB_PROC_HANDLER(EXT4_MB_STATS_NAME, stats);
@@ -2674,8 +2673,7 @@ static int ext4_mb_destroy_per_dev_proc(struct super_block *sb)
        if (sbi->s_mb_proc == NULL)
                return -EINVAL;
 
-       snprintf(devname, sizeof(devname) - 1, "%s",
-               bdevname(sb->s_bdev, devname));
+       bdevname(sb->s_bdev, devname);
        remove_proc_entry(EXT4_MB_GROUP_PREALLOC, sbi->s_mb_proc);
        remove_proc_entry(EXT4_MB_STREAM_REQ, sbi->s_mb_proc);
        remove_proc_entry(EXT4_MB_ORDER2_REQ, sbi->s_mb_proc);
index 53632e3e8457e6227a182b28ea0d75a49880c5f6..2e24567c4a797ddf5c18c481bf53eef8bc01ad50 100644 (file)
@@ -901,7 +901,7 @@ static void jbd2_stats_proc_init(journal_t *journal)
 {
        char name[BDEVNAME_SIZE];
 
-       snprintf(name, sizeof(name) - 1, "%s", bdevname(journal->j_dev, name));
+       bdevname(journal->j_dev, name);
        journal->j_proc_entry = proc_mkdir(name, proc_jbd2_stats);
        if (journal->j_proc_entry) {
                proc_create_data("history", S_IRUGO, journal->j_proc_entry,
@@ -915,7 +915,7 @@ static void jbd2_stats_proc_exit(journal_t *journal)
 {
        char name[BDEVNAME_SIZE];
 
-       snprintf(name, sizeof(name) - 1, "%s", bdevname(journal->j_dev, name));
+       bdevname(journal->j_dev, name);
        remove_proc_entry("info", journal->j_proc_entry);
        remove_proc_entry("history", journal->j_proc_entry);
        remove_proc_entry(name, proc_jbd2_stats);