Skip to content

Commit

Permalink
mlx4: fix DMA mapping leak when allocation fails
Browse files Browse the repository at this point in the history
mlx4_en_prepare_rx_desc does not correctly clean up after it finds an
allocation failure. It should unmap a page before calling put_page, but
it only calls the later.

This bug would prevent a device removal using hotplug after setting the
device MTU to 9000 and opening the network interface. After the fix, we
still see the allocation failure with MTU 9000, but we are able to
remove the device.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Thadeu Lima de Souza Cascardo authored and David S. Miller committed Feb 6, 2012
1 parent 68355f7 commit 7e2eb99
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion drivers/net/ethernet/mellanox/mlx4/en_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,12 @@ static int mlx4_en_prepare_rx_desc(struct mlx4_en_priv *priv,
return 0;

err:
while (i--)
while (i--) {
dma_addr_t dma = be64_to_cpu(rx_desc->data[i].addr);
pci_unmap_single(priv->mdev->pdev, dma, skb_frags[i].size,
PCI_DMA_FROMDEVICE);
put_page(skb_frags[i].page);
}
return -ENOMEM;
}

Expand Down

0 comments on commit 7e2eb99

Please sign in to comment.