aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJulia Lawall <julia@diku.dk>2010-05-22 04:21:02 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-08-02 14:20:28 -0400
commitc6cfe05532cf6e9858d60ee699c51b906842489d (patch)
treebc3dc3f1fd92ad0100bd88ec373a9524e20205c8 /drivers
parent3e9442c6f1d50bce083c5870f293647efbd6f828 (diff)
V4L/DVB: drivers/media: 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: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/dvb/dvb-core/dvb_demux.c10
-rw-r--r--drivers/media/video/dabusb.c13
2 files changed, 7 insertions, 16 deletions
diff --git a/drivers/media/dvb/dvb-core/dvb_demux.c b/drivers/media/dvb/dvb-core/dvb_demux.c
index 977ddba3e235..4a88a3e4db2b 100644
--- a/drivers/media/dvb/dvb-core/dvb_demux.c
+++ b/drivers/media/dvb/dvb-core/dvb_demux.c
@@ -1130,13 +1130,9 @@ static int dvbdmx_write(struct dmx_demux *demux, const char __user *buf, size_t
1130 if ((!demux->frontend) || (demux->frontend->source != DMX_MEMORY_FE)) 1130 if ((!demux->frontend) || (demux->frontend->source != DMX_MEMORY_FE))
1131 return -EINVAL; 1131 return -EINVAL;
1132 1132
1133 p = kmalloc(count, GFP_USER); 1133 p = memdup_user(buf, count);
1134 if (!p) 1134 if (IS_ERR(p))
1135 return -ENOMEM; 1135 return PTR_ERR(p);
1136 if (copy_from_user(p, buf, count)) {
1137 kfree(p);
1138 return -EFAULT;
1139 }
1140 if (mutex_lock_interruptible(&dvbdemux->mutex)) { 1136 if (mutex_lock_interruptible(&dvbdemux->mutex)) {
1141 kfree(p); 1137 kfree(p);
1142 return -ERESTARTSYS; 1138 return -ERESTARTSYS;
diff --git a/drivers/media/video/dabusb.c b/drivers/media/video/dabusb.c
index 0f505086774c..5b176bd7afdb 100644
--- a/drivers/media/video/dabusb.c
+++ b/drivers/media/video/dabusb.c
@@ -706,16 +706,11 @@ static long dabusb_ioctl (struct file *file, unsigned int cmd, unsigned long arg
706 switch (cmd) { 706 switch (cmd) {
707 707
708 case IOCTL_DAB_BULK: 708 case IOCTL_DAB_BULK:
709 pbulk = kmalloc(sizeof (bulk_transfer_t), GFP_KERNEL); 709 pbulk = memdup_user((void __user *)arg,
710 sizeof(bulk_transfer_t));
710 711
711 if (!pbulk) { 712 if (IS_ERR(pbulk)) {
712 ret = -ENOMEM; 713 ret = PTR_ERR(pbulk);
713 break;
714 }
715
716 if (copy_from_user (pbulk, (void __user *) arg, sizeof (bulk_transfer_t))) {
717 ret = -EFAULT;
718 kfree (pbulk);
719 break; 714 break;
720 } 715 }
721 716