* [PATCH] kernel: trace: blktrace: remove redundent memcpy() in compat_blk_trace_setup()
@ 2013-11-03 14:23 Chen Gang
2013-11-03 17:36 ` Steven Rostedt
0 siblings, 1 reply; 6+ messages in thread
From: Chen Gang @ 2013-11-03 14:23 UTC (permalink / raw)
To: Steven Rostedt, Frederic Weisbecker, Jens Axboe, Tejun Heo, Jan Kara
Cc: mingo, linux-kernel
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>
---
include/linux/blktrace_api.h | 2 +-
kernel/trace/blktrace.c | 3 +--
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
index a12f6ed..afc1343 100644
--- a/include/linux/blktrace_api.h
+++ b/include/linux/blktrace_api.h
@@ -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;
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index 7f727b3..f785aef 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -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;
}
--
1.7.7.6
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] kernel: trace: blktrace: remove redundent memcpy() in compat_blk_trace_setup()
2013-11-03 14:23 [PATCH] kernel: trace: blktrace: remove redundent memcpy() in compat_blk_trace_setup() Chen Gang
@ 2013-11-03 17:36 ` Steven Rostedt
2013-11-03 18:16 ` Jens Axboe
2013-11-04 0:55 ` Chen Gang
0 siblings, 2 replies; 6+ messages in thread
From: Steven Rostedt @ 2013-11-03 17:36 UTC (permalink / raw)
To: Chen Gang
Cc: Frederic Weisbecker, Jens Axboe, Tejun Heo, Jan Kara, mingo,
linux-kernel
A quick review of this patch looks fine to me.
Although, using ARRAY_SIZE() for a character string seems to me a bit
over paranoid. But I'm fine with it, as it makes sure that the string
is an array and not a pointer.
Jens,
Can you give me an Acked-by?
-- Steve
On Sun, 03 Nov 2013 22:23:39 +0800
Chen Gang <gang.chen@asianux.com> wrote:
> 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>
> ---
> include/linux/blktrace_api.h | 2 +-
> kernel/trace/blktrace.c | 3 +--
> 2 files changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
> index a12f6ed..afc1343 100644
> --- a/include/linux/blktrace_api.h
> +++ b/include/linux/blktrace_api.h
> @@ -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;
> diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
> index 7f727b3..f785aef 100644
> --- a/kernel/trace/blktrace.c
> +++ b/kernel/trace/blktrace.c
> @@ -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;
> }
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] kernel: trace: blktrace: remove redundent memcpy() in compat_blk_trace_setup()
2013-11-03 17:36 ` Steven Rostedt
@ 2013-11-03 18:16 ` Jens Axboe
2013-11-03 20:15 ` Steven Rostedt
2013-11-04 0:55 ` Chen Gang
1 sibling, 1 reply; 6+ messages in thread
From: Jens Axboe @ 2013-11-03 18:16 UTC (permalink / raw)
To: Steven Rostedt
Cc: Chen Gang, Frederic Weisbecker, Tejun Heo, Jan Kara, mingo, linux-kernel
On Sun, Nov 03 2013, Steven Rostedt wrote:
> A quick review of this patch looks fine to me.
>
> Although, using ARRAY_SIZE() for a character string seems to me a bit
> over paranoid. But I'm fine with it, as it makes sure that the string
> is an array and not a pointer.
>
> Jens,
>
> Can you give me an Acked-by?
Thanks, but I'll just queue it up with the other block bits for 3.13.
--
Jens Axboe
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] kernel: trace: blktrace: remove redundent memcpy() in compat_blk_trace_setup()
2013-11-03 18:16 ` Jens Axboe
@ 2013-11-03 20:15 ` Steven Rostedt
2013-11-04 0:51 ` Chen Gang
0 siblings, 1 reply; 6+ messages in thread
From: Steven Rostedt @ 2013-11-03 20:15 UTC (permalink / raw)
To: Jens Axboe
Cc: Chen Gang, Frederic Weisbecker, Tejun Heo, Jan Kara, mingo, linux-kernel
On Sun, 3 Nov 2013 11:16:39 -0700
Jens Axboe <axboe@kernel.dk> wrote:
> Thanks, but I'll just queue it up with the other block bits for 3.13.
>
OK,
-- Steve
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] kernel: trace: blktrace: remove redundent memcpy() in compat_blk_trace_setup()
2013-11-03 20:15 ` Steven Rostedt
@ 2013-11-04 0:51 ` Chen Gang
0 siblings, 0 replies; 6+ messages in thread
From: Chen Gang @ 2013-11-04 0:51 UTC (permalink / raw)
To: Steven Rostedt
Cc: Jens Axboe, Frederic Weisbecker, Tejun Heo, Jan Kara, mingo,
linux-kernel
On 11/04/2013 04:15 AM, Steven Rostedt wrote:
> On Sun, 3 Nov 2013 11:16:39 -0700
> Jens Axboe <axboe@kernel.dk> wrote:
>
>> Thanks, but I'll just queue it up with the other block bits for 3.13.
>>
>
> OK,
>
Thank all of you. :-)
--
Chen Gang
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] kernel: trace: blktrace: remove redundent memcpy() in compat_blk_trace_setup()
2013-11-03 17:36 ` Steven Rostedt
2013-11-03 18:16 ` Jens Axboe
@ 2013-11-04 0:55 ` Chen Gang
1 sibling, 0 replies; 6+ messages in thread
From: Chen Gang @ 2013-11-04 0:55 UTC (permalink / raw)
To: Steven Rostedt
Cc: Frederic Weisbecker, Jens Axboe, Tejun Heo, Jan Kara, mingo,
linux-kernel
On 11/04/2013 01:36 AM, Steven Rostedt wrote:
> A quick review of this patch looks fine to me.
>
> Although, using ARRAY_SIZE() for a character string seems to me a bit
> over paranoid. But I'm fine with it, as it makes sure that the string
> is an array and not a pointer.
>
Yeah.
> Jens,
>
> Can you give me an Acked-by?
>
I am glad to.
Thanks.
--
Chen Gang
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-11-04 0:56 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-03 14:23 [PATCH] kernel: trace: blktrace: remove redundent memcpy() in compat_blk_trace_setup() Chen Gang
2013-11-03 17:36 ` Steven Rostedt
2013-11-03 18:16 ` Jens Axboe
2013-11-03 20:15 ` Steven Rostedt
2013-11-04 0:51 ` Chen Gang
2013-11-04 0:55 ` Chen Gang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).