misc: eeprom/idt_89hpesx: Switch to memdup_user_nul() helper
[linux-2.6-microblaze.git] / drivers / misc / eeprom / idt_89hpesx.c
index 740c063..433a4bc 100644 (file)
@@ -913,15 +913,9 @@ static ssize_t idt_dbgfs_csr_write(struct file *filep, const char __user *ubuf,
                return 0;
 
        /* Copy data from User-space */
-       buf = kmalloc(count + 1, GFP_KERNEL);
-       if (!buf)
-               return -ENOMEM;
-
-       if (copy_from_user(buf, ubuf, count)) {
-               ret = -EFAULT;
-               goto free_buf;
-       }
-       buf[count] = 0;
+       buf = memdup_user_nul(ubuf, count);
+       if (IS_ERR(buf))
+               return PTR_ERR(buf);
 
        /* Find position of colon in the buffer */
        colon_ch = strnchr(buf, count, ':');