Skip to content

Commit

Permalink
Drivers: hv: utils: use memdup_user in hvt_op_write
Browse files Browse the repository at this point in the history
Use memdup_user to handle OOM.

Fixes: 14b50f8 ('Drivers: hv: util: introduce hv_utils_transport abstraction')

Signed-off-by: Olaf Hering <[email protected]>
Signed-off-by: K. Y. Srinivasan <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
olafhering authored and gregkh committed Dec 15, 2015
1 parent cdc0c0c commit b003596
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions drivers/hv/hv_utils_transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,10 @@ static ssize_t hvt_op_write(struct file *file, const char __user *buf,

hvt = container_of(file->f_op, struct hvutil_transport, fops);

inmsg = kzalloc(count, GFP_KERNEL);
if (copy_from_user(inmsg, buf, count)) {
kfree(inmsg);
return -EFAULT;
}
inmsg = memdup_user(buf, count);
if (IS_ERR(inmsg))
return PTR_ERR(inmsg);

if (hvt->on_msg(inmsg, count))
return -EFAULT;
kfree(inmsg);
Expand Down

0 comments on commit b003596

Please sign in to comment.