Skip to content
  • Mike Marciniszyn's avatar
    IB/hfi1: Fix user context tail allocation for DMA_RTAIL · 1bc0299d
    Mike Marciniszyn authored
    
    
    The following code fails to allocate a buffer for the
    tail address that the hardware DMAs into when the user
    context DMA_RTAIL is set.
    
    if (HFI1_CAP_KGET_MASK(rcd->flags, DMA_RTAIL)) {
    	rcd->rcvhdrtail_kvaddr = dma_zalloc_coherent(
    		&dd->pcidev->dev, PAGE_SIZE, &dma_hdrqtail,
                    gfp_flags);
    	if (!rcd->rcvhdrtail_kvaddr)
    		goto bail_free;
    	rcd->rcvhdrqtailaddr_dma = dma_hdrqtail;
    }
    
    So the rcvhdrtail_kvaddr would then be NULL.
    
    The mmap logic fails to check for a NULL rcvhdrtail_kvaddr.
    
    The fix is to test for both user and kernel DMA_TAIL options
    during the allocation as well as testing for a NULL
    rcvhdrtail_kvaddr during the mmap processing.
    
    Additionally, all downstream testing of the capmask for DMA_RTAIL
    have been eliminated in favor of testing rcvhdrtail_kvaddr.
    
    Cc: <stable@vger.kernel.org> # 4.9.x
    Reviewed-by: default avatarMichael J. Ruhl <michael.j.ruhl@intel.com>
    Signed-off-by: default avatarMike Marciniszyn <mike.marciniszyn@intel.com>
    Signed-off-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
    Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
    1bc0299d