diff --git a/sys/dev/mpi3mr/mpi3mr_app.c b/sys/dev/mpi3mr/mpi3mr_app.c --- a/sys/dev/mpi3mr/mpi3mr_app.c +++ b/sys/dev/mpi3mr/mpi3mr_app.c @@ -543,6 +543,7 @@ { U16 i, needed_desc = (dma_buffers->kern_buf_len / MPI3MR_IOCTL_SGE_SIZE); U32 buf_len = dma_buffers->kern_buf_len, copied_len = 0; + int error; if (dma_buffers->kern_buf_len % MPI3MR_IOCTL_SGE_SIZE) needed_desc++; @@ -558,6 +559,7 @@ if (!dma_buffers->dma_desc) return -1; + error = 0; for (i = 0; i < needed_desc; i++, desc_count++) { dma_buffers->dma_desc[i].addr = sc->ioctl_sge[desc_count].addr; @@ -572,12 +574,19 @@ memset(dma_buffers->dma_desc[i].addr, 0, sc->ioctl_sge[desc_count].size); if (dma_buffers->data_dir == MPI3MR_APP_DDO) { - copyin(((U8 *)dma_buffers->user_buf + copied_len), + error = copyin(((U8 *)dma_buffers->user_buf + copied_len), dma_buffers->dma_desc[i].addr, dma_buffers->dma_desc[i].size); + if (error != 0) + break; copied_len += dma_buffers->dma_desc[i].size; } } + if (error != 0) { + printf("%s: DMA copyin error %d\n", __func__, error); + free(dma_buffers->dma_desc, M_MPI3MR); + return -1; + } dma_buffers->num_dma_desc = needed_desc;