kernel: trace: blktrace: remove redundent memcpy() in compat_blk_trace_setup()
authorChen Gang <gang.chen@asianux.com>
Sun, 3 Nov 2013 14:23:39 +0000 (22:23 +0800)
committerJens Axboe <axboe@kernel.dk>
Fri, 8 Nov 2013 16:04:30 +0000 (09:04 -0700)
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>
include/linux/blktrace_api.h
kernel/trace/blktrace.c

index a12f6ed91c84abb65fea5dddd75243094f731585..afc1343df3c7ab3775c8fc2e822c4e619bf658c1 100644 (file)
@@ -89,7 +89,7 @@ static inline int blk_trace_init_sysfs(struct device *dev)
 #ifdef CONFIG_COMPAT
 
 struct compat_blk_user_trace_setup {
-       char name[32];
+       char name[BLKTRACE_BDEV_SIZE];
        u16 act_mask;
        u32 buf_size;
        u32 buf_nr;
index 7f727b34280d7315ba09f6ff9f2b54457e4c1ed7..f785aef65799cdb0068f0016bb0183a3bfe312a6 100644 (file)
@@ -579,13 +579,12 @@ static int compat_blk_trace_setup(struct request_queue *q, char *name,
                .end_lba = cbuts.end_lba,
                .pid = cbuts.pid,
        };
-       memcpy(&buts.name, &cbuts.name, 32);
 
        ret = do_blk_trace_setup(q, name, dev, bdev, &buts);
        if (ret)
                return ret;
 
-       if (copy_to_user(arg, &buts.name, 32)) {
+       if (copy_to_user(arg, &buts.name, ARRAY_SIZE(buts.name))) {
                blk_trace_remove(q);
                return -EFAULT;
        }