|
@@ -241,15 +241,9 @@ static ssize_t opal_prd_write(struct file *file, const char __user *buf,
|
|
|
|
|
|
size = be16_to_cpu(hdr.size);
|
|
size = be16_to_cpu(hdr.size);
|
|
|
|
|
|
- msg = kmalloc(size, GFP_KERNEL);
|
|
|
|
- if (!msg)
|
|
|
|
- return -ENOMEM;
|
|
|
|
-
|
|
|
|
- rc = copy_from_user(msg, buf, size);
|
|
|
|
- if (rc) {
|
|
|
|
- size = -EFAULT;
|
|
|
|
- goto out_free;
|
|
|
|
- }
|
|
|
|
|
|
+ msg = memdup_user(buf, size);
|
|
|
|
+ if (IS_ERR(msg))
|
|
|
|
+ return PTR_ERR(msg);
|
|
|
|
|
|
rc = opal_prd_msg(msg);
|
|
rc = opal_prd_msg(msg);
|
|
if (rc) {
|
|
if (rc) {
|
|
@@ -257,7 +251,6 @@ static ssize_t opal_prd_write(struct file *file, const char __user *buf,
|
|
size = -EIO;
|
|
size = -EIO;
|
|
}
|
|
}
|
|
|
|
|
|
-out_free:
|
|
|
|
kfree(msg);
|
|
kfree(msg);
|
|
|
|
|
|
return size;
|
|
return size;
|