ibmvnic: Unmap longer term buffer before free
authorBrian King <brking@linux.vnet.ibm.com>
Wed, 19 Apr 2017 17:44:41 +0000 (13:44 -0400)
committerDavid S. Miller <davem@davemloft.net>
Fri, 21 Apr 2017 17:33:52 +0000 (13:33 -0400)
Make sure we unregister long term buffers from the adapter
prior to DMA unmapping it and freeing the buffer. Failure
to do so could result in a DMA to a now invalid address.

Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/ibm/ibmvnic.c

index 625896de25f73c9c314f50bdcad50cd82b97fd78..c10bae7823e05498d913bd473eea93537253f6f6 100644 (file)
@@ -193,9 +193,9 @@ static void free_long_term_buff(struct ibmvnic_adapter *adapter,
        if (!ltb->buff)
                return;
 
-       dma_free_coherent(dev, ltb->size, ltb->buff, ltb->addr);
        if (!adapter->failover)
                send_request_unmap(adapter, ltb->map_id);
+       dma_free_coherent(dev, ltb->size, ltb->buff, ltb->addr);
 }
 
 static void replenish_rx_pool(struct ibmvnic_adapter *adapter,