Skip to content

Commit

Permalink
mic: vop: copy data to kernel space then write to io memory
Browse files Browse the repository at this point in the history
Read and write io memory should address align on ARCH ARM. Change to use
memcpy_toio to avoid kernel panic caused by the address un-align issue.

Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
  • Loading branch information
Sherry Sun authored and intel-lab-lkp committed Sep 25, 2020
1 parent 2ad4fa0 commit 5f4b5de
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion drivers/misc/mic/vop/vop_vringh.c
Expand Up @@ -602,6 +602,7 @@ static int vop_virtio_copy_from_user(struct vop_vdev *vdev, void __user *ubuf,
size_t partlen;
bool dma = VOP_USE_DMA && vi->dma_ch;
int err = 0;
void *temp = NULL;

if (dma) {
dma_alignment = 1 << vi->dma_ch->device->copy_align;
Expand Down Expand Up @@ -655,12 +656,15 @@ static int vop_virtio_copy_from_user(struct vop_vdev *vdev, void __user *ubuf,
* We are copying to IO below and should ideally use something
* like copy_from_user_toio(..) if it existed.
*/
if (copy_from_user((void __force *)dbuf, ubuf, len)) {
temp = kmalloc(len, GFP_KERNEL);
if (copy_from_user(temp, ubuf, len)) {
err = -EFAULT;
dev_err(vop_dev(vdev), "%s %d err %d\n",
__func__, __LINE__, err);
goto err;
}
memcpy_toio((void __force *)dbuf, temp, len);
kfree(temp);
vdev->out_bytes += len;
err = 0;
err:
Expand Down

0 comments on commit 5f4b5de

Please sign in to comment.