diff options
author | Julia Lawall <julia@diku.dk> | 2010-05-26 17:42:11 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-27 12:12:40 -0400 |
commit | 9b71ca2005a93ad813b95d92578131ab899ccc5d (patch) | |
tree | 9579c7b16e155de25c23ee227a11c62817e14ec4 /drivers/char | |
parent | dc0fd7b56141999832a6bccda2f7e9765f0bc087 (diff) |
drivers/char/vt.c: use memdup_user
Use memdup_user when user data is immediately copied into the
allocated region.
The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@
expression from,to,size,flag;
position p;
identifier l1,l2;
@@
- to = \(kmalloc@p\|kzalloc@p\)(size,flag);
+ to = memdup_user(from,size);
if (
- to==NULL
+ IS_ERR(to)
|| ...) {
<+... when != goto l1;
- -ENOMEM
+ PTR_ERR(to)
...+>
}
- if (copy_from_user(to, from, size) != 0) {
- <+... when != goto l2;
- -EFAULT
- ...+>
- }
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/vt.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/drivers/char/vt.c b/drivers/char/vt.c index bd1d1164fec5..7cdb6ee569cd 100644 --- a/drivers/char/vt.c +++ b/drivers/char/vt.c | |||
@@ -3967,13 +3967,9 @@ static int con_font_set(struct vc_data *vc, struct console_font_op *op) | |||
3967 | font.charcount = op->charcount; | 3967 | font.charcount = op->charcount; |
3968 | font.height = op->height; | 3968 | font.height = op->height; |
3969 | font.width = op->width; | 3969 | font.width = op->width; |
3970 | font.data = kmalloc(size, GFP_KERNEL); | 3970 | font.data = memdup_user(op->data, size); |
3971 | if (!font.data) | 3971 | if (IS_ERR(font.data)) |
3972 | return -ENOMEM; | 3972 | return PTR_ERR(font.data); |
3973 | if (copy_from_user(font.data, op->data, size)) { | ||
3974 | kfree(font.data); | ||
3975 | return -EFAULT; | ||
3976 | } | ||
3977 | acquire_console_sem(); | 3973 | acquire_console_sem(); |
3978 | if (vc->vc_sw->con_font_set) | 3974 | if (vc->vc_sw->con_font_set) |
3979 | rc = vc->vc_sw->con_font_set(vc, &font, op->flags); | 3975 | rc = vc->vc_sw->con_font_set(vc, &font, op->flags); |