Commit cbf9074c authored by Michael Ellerman's avatar Michael Ellerman Committed by Jeff Garzik

[PATCH] iseries_veth: Only call dma_unmap_single() if dma_map_single() succeeded

The iseries_veth driver unconditionally calls dma_unmap_single() even
when the corresponding dma_map_single() may have failed.

Rework the code a bit to keep the return value from dma_unmap_single()
around, and then check if it's a dma_mapping_error() before we do
the dma_unmap_single().
Signed-off-by: default avatarMichael Ellerman <michael@ellerman.id.au>
Signed-off-by: default avatarJeff Garzik <jgarzik@pobox.com>
parent b08bd5c0
...@@ -931,7 +931,6 @@ static int veth_transmit_to_one(struct sk_buff *skb, HvLpIndex rlp, ...@@ -931,7 +931,6 @@ static int veth_transmit_to_one(struct sk_buff *skb, HvLpIndex rlp,
struct veth_lpar_connection *cnx = veth_cnx[rlp]; struct veth_lpar_connection *cnx = veth_cnx[rlp];
struct veth_port *port = (struct veth_port *) dev->priv; struct veth_port *port = (struct veth_port *) dev->priv;
HvLpEvent_Rc rc; HvLpEvent_Rc rc;
u32 dma_address, dma_length;
struct veth_msg *msg = NULL; struct veth_msg *msg = NULL;
int err = 0; int err = 0;
unsigned long flags; unsigned long flags;
...@@ -959,20 +958,19 @@ static int veth_transmit_to_one(struct sk_buff *skb, HvLpIndex rlp, ...@@ -959,20 +958,19 @@ static int veth_transmit_to_one(struct sk_buff *skb, HvLpIndex rlp,
msg->in_use = 1; msg->in_use = 1;
dma_length = skb->len; msg->data.addr[0] = dma_map_single(port->dev, skb->data,
dma_address = dma_map_single(port->dev, skb->data, skb->len, DMA_TO_DEVICE);
dma_length, DMA_TO_DEVICE);
if (dma_mapping_error(dma_address)) if (dma_mapping_error(msg->data.addr[0]))
goto recycle_and_drop; goto recycle_and_drop;
/* Is it really necessary to check the length and address /* Is it really necessary to check the length and address
* fields of the first entry here? */ * fields of the first entry here? */
msg->skb = skb; msg->skb = skb;
msg->dev = port->dev; msg->dev = port->dev;
msg->data.addr[0] = dma_address; msg->data.len[0] = skb->len;
msg->data.len[0] = dma_length;
msg->data.eofmask = 1 << VETH_EOF_SHIFT; msg->data.eofmask = 1 << VETH_EOF_SHIFT;
rc = veth_signaldata(cnx, VethEventTypeFrames, msg->token, &msg->data); rc = veth_signaldata(cnx, VethEventTypeFrames, msg->token, &msg->data);
if (rc != HvLpEvent_Rc_Good) if (rc != HvLpEvent_Rc_Good)
...@@ -1076,8 +1074,9 @@ static void veth_recycle_msg(struct veth_lpar_connection *cnx, ...@@ -1076,8 +1074,9 @@ static void veth_recycle_msg(struct veth_lpar_connection *cnx,
dma_address = msg->data.addr[0]; dma_address = msg->data.addr[0];
dma_length = msg->data.len[0]; dma_length = msg->data.len[0];
dma_unmap_single(msg->dev, dma_address, dma_length, if (!dma_mapping_error(dma_address))
DMA_TO_DEVICE); dma_unmap_single(msg->dev, dma_address, dma_length,
DMA_TO_DEVICE);
if (msg->skb) { if (msg->skb) {
dev_kfree_skb_any(msg->skb); dev_kfree_skb_any(msg->skb);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment