diff options
author | Julia Lawall <julia@diku.dk> | 2010-05-26 17:42:32 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-27 12:12:42 -0400 |
commit | b8d6b0d6b6882a53e4586a07e1292223d55299d1 (patch) | |
tree | 057cd0237cbd37ccd17d497a415163432a8be9b1 /drivers/telephony | |
parent | 8fc809d17984f18fbad7ae23e47a62b195969c19 (diff) |
drivers/telephony/ixj.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/telephony')
-rw-r--r-- | drivers/telephony/ixj.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/drivers/telephony/ixj.c b/drivers/telephony/ixj.c index e89304c72568..b53deee25d74 100644 --- a/drivers/telephony/ixj.c +++ b/drivers/telephony/ixj.c | |||
@@ -5879,20 +5879,13 @@ out: | |||
5879 | static int ixj_build_filter_cadence(IXJ *j, IXJ_FILTER_CADENCE __user * cp) | 5879 | static int ixj_build_filter_cadence(IXJ *j, IXJ_FILTER_CADENCE __user * cp) |
5880 | { | 5880 | { |
5881 | IXJ_FILTER_CADENCE *lcp; | 5881 | IXJ_FILTER_CADENCE *lcp; |
5882 | lcp = kmalloc(sizeof(IXJ_FILTER_CADENCE), GFP_KERNEL); | 5882 | lcp = memdup_user(cp, sizeof(IXJ_FILTER_CADENCE)); |
5883 | if (lcp == NULL) { | 5883 | if (IS_ERR(lcp)) { |
5884 | if(ixjdebug & 0x0001) { | 5884 | if(ixjdebug & 0x0001) { |
5885 | printk(KERN_INFO "Could not allocate memory for cadence\n"); | 5885 | printk(KERN_INFO "Could not allocate memory for cadence or could not copy cadence to kernel\n"); |
5886 | } | 5886 | } |
5887 | return -ENOMEM; | 5887 | return PTR_ERR(lcp); |
5888 | } | 5888 | } |
5889 | if (copy_from_user(lcp, cp, sizeof(IXJ_FILTER_CADENCE))) { | ||
5890 | if(ixjdebug & 0x0001) { | ||
5891 | printk(KERN_INFO "Could not copy cadence to kernel\n"); | ||
5892 | } | ||
5893 | kfree(lcp); | ||
5894 | return -EFAULT; | ||
5895 | } | ||
5896 | if (lcp->filter > 5) { | 5889 | if (lcp->filter > 5) { |
5897 | if(ixjdebug & 0x0001) { | 5890 | if(ixjdebug & 0x0001) { |
5898 | printk(KERN_INFO "Cadence out of range\n"); | 5891 | printk(KERN_INFO "Cadence out of range\n"); |