@@ -1147,15 +1147,16 @@ static uint16_t nvme_tx(NvmeCtrl *n, NvmeSg *sg, uint8_t *ptr, uint32_t len,
if (sg->flags & NVME_SG_DMA) {
const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED;
+ MemTxResult res;
uint64_t residual;
if (dir == NVME_TX_DIRECTION_TO_DEVICE) {
- dma_buf_write(ptr, len, &residual, &sg->qsg, attrs);
+ res = dma_buf_write(ptr, len, &residual, &sg->qsg, attrs);
} else {
- dma_buf_read(ptr, len, &residual, &sg->qsg, attrs);
+ res = dma_buf_read(ptr, len, &residual, &sg->qsg, attrs);
}
- if (unlikely(residual)) {
+ if (unlikely(residual) || res != MEMTX_OK) {
trace_pci_nvme_err_invalid_dma();
return NVME_INVALID_FIELD | NVME_DNR;
}
dma_buf_read/dma_buf_write() return a MemTxResult type. Do not discard it, propagate the DMA error to the caller. Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> --- hw/nvme/ctrl.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)