Skip to content

Commit 756af9c

Browse files
Tyrel Datwylerdavem330
authored andcommitted
ibmveth: fix DMA unmap error in ibmveth_xmit_start error path
Commit 33a48ab ("ibmveth: Fix DMA unmap error") fixed an issue in the normal code path of ibmveth_xmit_start() that was originally introduced by Commit 6e8ab30 ("ibmveth: Add scatter-gather support"). This original fix missed the error path where dma_unmap_page is wrongly called on the header portion in descs[0] which was mapped with dma_map_single. As a result a failure to DMA map any of the frags results in a dmesg warning when CONFIG_DMA_API_DEBUG is enabled. ------------[ cut here ]------------ DMA-API: ibmveth 30000002: device driver frees DMA memory with wrong function [device address=0x000000000a430000] [size=172 bytes] [mapped as page] [unmapped as single] WARNING: CPU: 1 PID: 8426 at kernel/dma/debug.c:1085 check_unmap+0x4fc/0xe10 ... <snip> ... DMA-API: Mapped at: ibmveth_start_xmit+0x30c/0xb60 dev_hard_start_xmit+0x100/0x450 sch_direct_xmit+0x224/0x490 __qdisc_run+0x20c/0x980 __dev_queue_xmit+0x1bc/0xf20 This fixes the API misuse by unampping descs[0] with dma_unmap_single. Fixes: 6e8ab30 ("ibmveth: Add scatter-gather support") Signed-off-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 3bd8264 commit 756af9c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/net/ethernet/ibm/ibmveth.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1171,11 +1171,15 @@ static netdev_tx_t ibmveth_start_xmit(struct sk_buff *skb,
11711171

11721172
map_failed_frags:
11731173
last = i+1;
1174-
for (i = 0; i < last; i++)
1174+
for (i = 1; i < last; i++)
11751175
dma_unmap_page(&adapter->vdev->dev, descs[i].fields.address,
11761176
descs[i].fields.flags_len & IBMVETH_BUF_LEN_MASK,
11771177
DMA_TO_DEVICE);
11781178

1179+
dma_unmap_single(&adapter->vdev->dev,
1180+
descs[0].fields.address,
1181+
descs[0].fields.flags_len & IBMVETH_BUF_LEN_MASK,
1182+
DMA_TO_DEVICE);
11791183
map_failed:
11801184
if (!firmware_has_feature(FW_FEATURE_CMO))
11811185
netdev_err(netdev, "tx: unable to map xmit buffer\n");

0 commit comments

Comments
 (0)