Commit f8c5e94486671ffcac696886c246baa6ba89b5cf

Authored by Chen Gang
Committed by Jens Axboe
1 parent 6678d83f18

kernel: trace: blktrace: remove redundent memcpy() in compat_blk_trace_setup()

do_blk_trace_setup() will fully initialize 'buts.name', so can remove
the related memcpy(). And also use BLKTRACE_BDEV_SIZE and ARRAY_SIZE
instead of hard code number '32'.

Signed-off-by: Chen Gang <gang.chen@asianux.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

Showing 2 changed files with 2 additions and 3 deletions Side-by-side Diff

include/linux/blktrace_api.h
... ... @@ -89,7 +89,7 @@
89 89 #ifdef CONFIG_COMPAT
90 90  
91 91 struct compat_blk_user_trace_setup {
92   - char name[32];
  92 + char name[BLKTRACE_BDEV_SIZE];
93 93 u16 act_mask;
94 94 u32 buf_size;
95 95 u32 buf_nr;
kernel/trace/blktrace.c
... ... @@ -579,13 +579,12 @@
579 579 .end_lba = cbuts.end_lba,
580 580 .pid = cbuts.pid,
581 581 };
582   - memcpy(&buts.name, &cbuts.name, 32);
583 582  
584 583 ret = do_blk_trace_setup(q, name, dev, bdev, &buts);
585 584 if (ret)
586 585 return ret;
587 586  
588   - if (copy_to_user(arg, &buts.name, 32)) {
  587 + if (copy_to_user(arg, &buts.name, ARRAY_SIZE(buts.name))) {
589 588 blk_trace_remove(q);
590 589 return -EFAULT;
591 590 }