infiniband/mlx4: check for mapping error
authorSebastian Ott <sebott@linux.vnet.ibm.com>
Mon, 16 Mar 2015 17:49:59 +0000 (18:49 +0100)
committerDoug Ledford <dledford@redhat.com>
Wed, 15 Apr 2015 20:06:39 +0000 (16:06 -0400)
Since ib_dma_map_single can fail use ib_dma_mapping_error to check
for errors.

Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Acked-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/hw/mlx4/mad.c
drivers/infiniband/hw/mlx4/qp.c

index 5904026..9cd2b00 100644 (file)
@@ -1430,6 +1430,10 @@ static int mlx4_ib_alloc_pv_bufs(struct mlx4_ib_demux_pv_ctx *ctx,
                                                        tun_qp->ring[i].addr,
                                                        rx_buf_size,
                                                        DMA_FROM_DEVICE);
+               if (ib_dma_mapping_error(ctx->ib_dev, tun_qp->ring[i].map)) {
+                       kfree(tun_qp->ring[i].addr);
+                       goto err;
+               }
        }
 
        for (i = 0; i < MLX4_NUM_TUNNEL_BUFS; i++) {
@@ -1442,6 +1446,11 @@ static int mlx4_ib_alloc_pv_bufs(struct mlx4_ib_demux_pv_ctx *ctx,
                                          tun_qp->tx_ring[i].buf.addr,
                                          tx_buf_size,
                                          DMA_TO_DEVICE);
+               if (ib_dma_mapping_error(ctx->ib_dev,
+                                        tun_qp->tx_ring[i].buf.map)) {
+                       kfree(tun_qp->tx_ring[i].buf.addr);
+                       goto tx_err;
+               }
                tun_qp->tx_ring[i].ah = NULL;
        }
        spin_lock_init(&tun_qp->tx_lock);
index ed2bd67..0766550 100644 (file)
@@ -566,6 +566,10 @@ static int alloc_proxy_bufs(struct ib_device *dev, struct mlx4_ib_qp *qp)
                        ib_dma_map_single(dev, qp->sqp_proxy_rcv[i].addr,
                                          sizeof (struct mlx4_ib_proxy_sqp_hdr),
                                          DMA_FROM_DEVICE);
+               if (ib_dma_mapping_error(dev, qp->sqp_proxy_rcv[i].map)) {
+                       kfree(qp->sqp_proxy_rcv[i].addr);
+                       goto err;
+               }
        }
        return 0;