Created attachment 271441 [details] Fix mpi3mr dma_desc double free on DATA_OUT copyin failure In sys/dev/mpi3mr/mpi3mr_app.c, mpi3mr_map_data_buffer_dma() allocates dma_buffers->dma_desc before copying DATA_OUT payload data from userspace. If that copyin() fails, the function frees dma_buffers->dma_desc and returns an error, but leaves dma_buffers->dma_desc pointing at the freed allocation. The caller, mpi3mr_app_mptcmds(), handles the mapping failure by jumping to its common out: cleanup path. That path iterates over all dma_buffers entries and calls free(dma_buff->dma_desc, M_MPI3MR). For the DATA_OUT buffer whose copyin() failed, this frees the same dma_desc allocation a second time. I could not reproduce this with stock QEMU because QEMU does not provide an mpi3mr/SAS4116 device model, but a small logic harness that models the error path reports one double free in the buggy path. Set dma_buffers->dma_desc to NULL after freeing it in the copyin error branch.