]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - drivers/video/via/viafbdev.c
drivers/video/via: use memdup_user
[net-next-2.6.git] / drivers / video / via / viafbdev.c
index 2bc40e682f9509acd5ede1696058aebbdcfeea92..1082541358f01aaa4799f4c287b700c7cd8eafee 100644 (file)
@@ -578,14 +578,9 @@ static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg)
                break;
 
        case VIAFB_SET_GAMMA_LUT:
-               viafb_gamma_table = kmalloc(256 * sizeof(u32), GFP_KERNEL);
-               if (!viafb_gamma_table)
-                       return -ENOMEM;
-               if (copy_from_user(viafb_gamma_table, argp,
-                               256 * sizeof(u32))) {
-                       kfree(viafb_gamma_table);
-                       return -EFAULT;
-               }
+               viafb_gamma_table = memdup_user(argp, 256 * sizeof(u32));
+               if (IS_ERR(viafb_gamma_table))
+                       return PTR_ERR(viafb_gamma_table);
                viafb_set_gamma_table(viafb_bpp, viafb_gamma_table);
                kfree(viafb_gamma_table);
                break;