Skip to content

Commit d78a671

Browse files
Nick Childkuba-moo
authored andcommitted
ibmvnic: Handle DMA unmapping of login buffs in release functions
Rather than leaving the DMA unmapping of the login buffers to the login response handler, move this work into the login release functions. Previously, these functions were only used for freeing the allocated buffers. This could lead to issues if there are more than one outstanding login buffer requests, which is possible if a login request times out. If a login request times out, then there is another call to send login. The send login function makes a call to the login buffer release function. In the past, this freed the buffers but did not DMA unmap. Therefore, the VIOS could still write to the old login (now freed) buffer. It is for this reason that it is a good idea to leave the DMA unmap call to the login buffers release function. Since the login buffer release functions now handle DMA unmapping, remove the duplicate DMA unmapping in handle_login_rsp(). Fixes: dff515a ("ibmvnic: Harden device login requests") Signed-off-by: Nick Child <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 411c565 commit d78a671

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

drivers/net/ethernet/ibm/ibmvnic.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,12 +1588,22 @@ static int ibmvnic_login(struct net_device *netdev)
15881588

15891589
static void release_login_buffer(struct ibmvnic_adapter *adapter)
15901590
{
1591+
if (!adapter->login_buf)
1592+
return;
1593+
1594+
dma_unmap_single(&adapter->vdev->dev, adapter->login_buf_token,
1595+
adapter->login_buf_sz, DMA_TO_DEVICE);
15911596
kfree(adapter->login_buf);
15921597
adapter->login_buf = NULL;
15931598
}
15941599

15951600
static void release_login_rsp_buffer(struct ibmvnic_adapter *adapter)
15961601
{
1602+
if (!adapter->login_rsp_buf)
1603+
return;
1604+
1605+
dma_unmap_single(&adapter->vdev->dev, adapter->login_rsp_buf_token,
1606+
adapter->login_rsp_buf_sz, DMA_FROM_DEVICE);
15971607
kfree(adapter->login_rsp_buf);
15981608
adapter->login_rsp_buf = NULL;
15991609
}
@@ -5411,11 +5421,6 @@ static int handle_login_rsp(union ibmvnic_crq *login_rsp_crq,
54115421
}
54125422
adapter->login_pending = false;
54135423

5414-
dma_unmap_single(dev, adapter->login_buf_token, adapter->login_buf_sz,
5415-
DMA_TO_DEVICE);
5416-
dma_unmap_single(dev, adapter->login_rsp_buf_token,
5417-
adapter->login_rsp_buf_sz, DMA_FROM_DEVICE);
5418-
54195424
/* If the number of queues requested can't be allocated by the
54205425
* server, the login response will return with code 1. We will need
54215426
* to resend the login buffer with fewer queues requested.

0 commit comments

Comments
 (0)