diff options
author | Jean Delvare <khali@linux-fr.org> | 2008-05-12 17:02:33 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-05-13 11:02:26 -0400 |
commit | f36f21ecca9ee688301174e5f2e0827827a7a7ff (patch) | |
tree | b147bb5cc37683dfe01c86fba634808aa2ff567d | |
parent | 78bb6cb9a890d3d50ca3b02fce9223d3e734ab9b (diff) |
Fix misuses of bdevname()
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>
-rw-r--r-- | block/blktrace.c | 2 | ||||
-rw-r--r-- | block/compat_ioctl.c | 2 | ||||
-rw-r--r-- | fs/ext4/mballoc.c | 6 | ||||
-rw-r--r-- | fs/jbd2/journal.c | 4 |
4 files changed, 6 insertions, 8 deletions
diff --git a/block/blktrace.c b/block/blktrace.c index 568588cd16b2..b2cbb4e5d767 100644 --- a/block/blktrace.c +++ b/block/blktrace.c | |||
@@ -476,7 +476,7 @@ int blk_trace_ioctl(struct block_device *bdev, unsigned cmd, char __user *arg) | |||
476 | 476 | ||
477 | switch (cmd) { | 477 | switch (cmd) { |
478 | case BLKTRACESETUP: | 478 | case BLKTRACESETUP: |
479 | strcpy(b, bdevname(bdev, b)); | 479 | bdevname(bdev, b); |
480 | ret = blk_trace_setup(q, b, bdev->bd_dev, arg); | 480 | ret = blk_trace_setup(q, b, bdev->bd_dev, arg); |
481 | break; | 481 | break; |
482 | case BLKTRACESTART: | 482 | case BLKTRACESTART: |
diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c index c70d0b6f666f..c23177e4623f 100644 --- a/block/compat_ioctl.c +++ b/block/compat_ioctl.c | |||
@@ -555,7 +555,7 @@ static int compat_blk_trace_setup(struct block_device *bdev, char __user *arg) | |||
555 | if (copy_from_user(&cbuts, arg, sizeof(cbuts))) | 555 | if (copy_from_user(&cbuts, arg, sizeof(cbuts))) |
556 | return -EFAULT; | 556 | return -EFAULT; |
557 | 557 | ||
558 | strcpy(b, bdevname(bdev, b)); | 558 | bdevname(bdev, b); |
559 | 559 | ||
560 | buts = (struct blk_user_trace_setup) { | 560 | buts = (struct blk_user_trace_setup) { |
561 | .act_mask = cbuts.act_mask, | 561 | .act_mask = cbuts.act_mask, |
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index fbec2ef93797..b128bdc0f55c 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c | |||
@@ -2639,8 +2639,7 @@ static int ext4_mb_init_per_dev_proc(struct super_block *sb) | |||
2639 | struct proc_dir_entry *proc; | 2639 | struct proc_dir_entry *proc; |
2640 | char devname[64]; | 2640 | char devname[64]; |
2641 | 2641 | ||
2642 | snprintf(devname, sizeof(devname) - 1, "%s", | 2642 | bdevname(sb->s_bdev, devname); |
2643 | bdevname(sb->s_bdev, devname)); | ||
2644 | sbi->s_mb_proc = proc_mkdir(devname, proc_root_ext4); | 2643 | sbi->s_mb_proc = proc_mkdir(devname, proc_root_ext4); |
2645 | 2644 | ||
2646 | MB_PROC_HANDLER(EXT4_MB_STATS_NAME, stats); | 2645 | MB_PROC_HANDLER(EXT4_MB_STATS_NAME, stats); |
@@ -2674,8 +2673,7 @@ static int ext4_mb_destroy_per_dev_proc(struct super_block *sb) | |||
2674 | if (sbi->s_mb_proc == NULL) | 2673 | if (sbi->s_mb_proc == NULL) |
2675 | return -EINVAL; | 2674 | return -EINVAL; |
2676 | 2675 | ||
2677 | snprintf(devname, sizeof(devname) - 1, "%s", | 2676 | bdevname(sb->s_bdev, devname); |
2678 | bdevname(sb->s_bdev, devname)); | ||
2679 | remove_proc_entry(EXT4_MB_GROUP_PREALLOC, sbi->s_mb_proc); | 2677 | remove_proc_entry(EXT4_MB_GROUP_PREALLOC, sbi->s_mb_proc); |
2680 | remove_proc_entry(EXT4_MB_STREAM_REQ, sbi->s_mb_proc); | 2678 | remove_proc_entry(EXT4_MB_STREAM_REQ, sbi->s_mb_proc); |
2681 | remove_proc_entry(EXT4_MB_ORDER2_REQ, sbi->s_mb_proc); | 2679 | remove_proc_entry(EXT4_MB_ORDER2_REQ, sbi->s_mb_proc); |
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index 53632e3e8457..2e24567c4a79 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c | |||
@@ -901,7 +901,7 @@ static void jbd2_stats_proc_init(journal_t *journal) | |||
901 | { | 901 | { |
902 | char name[BDEVNAME_SIZE]; | 902 | char name[BDEVNAME_SIZE]; |
903 | 903 | ||
904 | snprintf(name, sizeof(name) - 1, "%s", bdevname(journal->j_dev, name)); | 904 | bdevname(journal->j_dev, name); |
905 | journal->j_proc_entry = proc_mkdir(name, proc_jbd2_stats); | 905 | journal->j_proc_entry = proc_mkdir(name, proc_jbd2_stats); |
906 | if (journal->j_proc_entry) { | 906 | if (journal->j_proc_entry) { |
907 | proc_create_data("history", S_IRUGO, journal->j_proc_entry, | 907 | proc_create_data("history", S_IRUGO, journal->j_proc_entry, |
@@ -915,7 +915,7 @@ static void jbd2_stats_proc_exit(journal_t *journal) | |||
915 | { | 915 | { |
916 | char name[BDEVNAME_SIZE]; | 916 | char name[BDEVNAME_SIZE]; |
917 | 917 | ||
918 | snprintf(name, sizeof(name) - 1, "%s", bdevname(journal->j_dev, name)); | 918 | bdevname(journal->j_dev, name); |
919 | remove_proc_entry("info", journal->j_proc_entry); | 919 | remove_proc_entry("info", journal->j_proc_entry); |
920 | remove_proc_entry("history", journal->j_proc_entry); | 920 | remove_proc_entry("history", journal->j_proc_entry); |
921 | remove_proc_entry(name, proc_jbd2_stats); | 921 | remove_proc_entry(name, proc_jbd2_stats); |