lkml.org 
[lkml]   [2019]   [Aug]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH 09/15] drivers/acrn: add passthrough device support
On Fri, Aug 16, 2019 at 10:25:50AM +0800, Zhao Yakui wrote:
> + case IC_ASSIGN_PTDEV: {
> + unsigned short bdf;
> +
> + if (copy_from_user(&bdf, (void *)ioctl_param,

This casting is ugly and you also need a __user tag for Sparse. Do
something like "void __user *p = ioctl_param;"

> + sizeof(unsigned short)))
> + return -EFAULT;
> +
> + ret = hcall_assign_ptdev(vm->vmid, bdf);
> + if (ret < 0) {
> + pr_err("acrn: failed to assign ptdev!\n");
> + return -EFAULT;

Preserve the error code. "return ret;".

> + }
> + break;
> + }
> + case IC_DEASSIGN_PTDEV: {
> + unsigned short bdf;
> +
> + if (copy_from_user(&bdf, (void *)ioctl_param,
> + sizeof(unsigned short)))
> + return -EFAULT;
> +
> + ret = hcall_deassign_ptdev(vm->vmid, bdf);
> + if (ret < 0) {
> + pr_err("acrn: failed to deassign ptdev!\n");
> + return -EFAULT;
> + }
> + break;
> + }
> +
> + case IC_SET_PTDEV_INTR_INFO: {
> + struct ic_ptdev_irq ic_pt_irq;
> + struct hc_ptdev_irq *hc_pt_irq;
> +
> + if (copy_from_user(&ic_pt_irq, (void *)ioctl_param,
> + sizeof(ic_pt_irq)))
> + return -EFAULT;
> +
> + hc_pt_irq = kmalloc(sizeof(*hc_pt_irq), GFP_KERNEL);
> + if (!hc_pt_irq)
> + return -ENOMEM;
> +
> + memcpy(hc_pt_irq, &ic_pt_irq, sizeof(*hc_pt_irq));

Use memdup_user().

> +
> + ret = hcall_set_ptdev_intr_info(vm->vmid,
> + virt_to_phys(hc_pt_irq));
> + kfree(hc_pt_irq);
> + if (ret < 0) {
> + pr_err("acrn: failed to set intr info for ptdev!\n");
> + return -EFAULT;
> + }
> +
> + break;
> + }

regards,
dan carpenter

\
 
 \ /
  Last update: 2019-08-16 15:26    [W:0.162 / U:3.380 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site