Merge remote-tracking branch 'lightnvm/for-next'
[deliverable/linux.git] / drivers / media / dvb-core / dvb_frontend.c
index be99c8dbc5f8f334cb265e49c3e090c733d08290..01511e5a5566643a32d03ba64fe314c299860ef6 100644 (file)
@@ -1969,17 +1969,9 @@ static int dvb_frontend_ioctl_properties(struct file *file,
                if ((tvps->num == 0) || (tvps->num > DTV_IOCTL_MAX_MSGS))
                        return -EINVAL;
 
-               tvp = kmalloc(tvps->num * sizeof(struct dtv_property), GFP_KERNEL);
-               if (!tvp) {
-                       err = -ENOMEM;
-                       goto out;
-               }
-
-               if (copy_from_user(tvp, (void __user *)tvps->props,
-                                  tvps->num * sizeof(struct dtv_property))) {
-                       err = -EFAULT;
-                       goto out;
-               }
+               tvp = memdup_user(tvps->props, tvps->num * sizeof(*tvp));
+               if (IS_ERR(tvp))
+                       return PTR_ERR(tvp);
 
                for (i = 0; i < tvps->num; i++) {
                        err = dtv_property_process_set(fe, tvp + i, file);
@@ -2002,17 +1994,9 @@ static int dvb_frontend_ioctl_properties(struct file *file,
                if ((tvps->num == 0) || (tvps->num > DTV_IOCTL_MAX_MSGS))
                        return -EINVAL;
 
-               tvp = kmalloc(tvps->num * sizeof(struct dtv_property), GFP_KERNEL);
-               if (!tvp) {
-                       err = -ENOMEM;
-                       goto out;
-               }
-
-               if (copy_from_user(tvp, (void __user *)tvps->props,
-                                  tvps->num * sizeof(struct dtv_property))) {
-                       err = -EFAULT;
-                       goto out;
-               }
+               tvp = memdup_user(tvps->props, tvps->num * sizeof(*tvp));
+               if (IS_ERR(tvp))
+                       return PTR_ERR(tvp);
 
                /*
                 * Let's use our own copy of property cache, in order to
This page took 0.072624 seconds and 5 git commands to generate.