diff mbox

infiniband/mlx4: check for mapping error

Message ID alpine.LFD.2.11.1503161844400.1763@denkbrett (mailing list archive)
State Rejected
Headers show

Commit Message

Sebastian Ott March 16, 2015, 5:49 p.m. UTC
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>
---
 drivers/infiniband/hw/mlx4/mad.c |    9 +++++++++
 drivers/infiniband/hw/mlx4/qp.c  |    4 ++++
 2 files changed, 13 insertions(+)


--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

jackm March 17, 2015, 4:46 p.m. UTC | #1
On Mon, 16 Mar 2015 18:49:59 +0100 (CET)
Sebastian Ott <sebott@linux.vnet.ibm.com> wrote:

> From: Sebastian Ott <sebott@linux.vnet.ibm.com>
> To: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org
> cc: Roland Dreier <roland@kernel.org>, Sean Hefty
> <sean.hefty@intel.com>, Hal Rosenstock <hal.rosenstock@gmail.com>, Or
> Gerlitz <ogerlitz@mellanox.com>, "David S. Miller"
> <davem@davemloft.net>, Yishai Hadas <yishaih@mellanox.com>, Ira Weiny
> <ira.weiny@intel.com>, Jack Morgenstein <jackm@dev.mellanox.co.il>,
> Matan Barak <matanb@mellanox.com>, Moni Shoua <monis@mellanox.com>,
> Jiri Kosina <jkosina@suse.cz> Subject: [PATCH] infiniband/mlx4: check
> for mapping error Date: Mon, 16 Mar 2015 18:49:59 +0100 (CET)
> User-Agent: Alpine 2.11 (LFD 23 2013-08-11) Organization: "IBM
> Deutschland Research & Development GmbH / Vorsitzende des
> Aufsichtsrats: Martina Koederitz Geschäftsführung: Dirk Wittkopp Sitz
> der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart,
> HRB 243294"
> 
> 
> 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>

> ---

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1418,6 +1418,10 @@  static int mlx4_ib_alloc_pv_bufs(struct
 							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++) {
@@ -1430,6 +1434,11 @@  static int mlx4_ib_alloc_pv_bufs(struct
 					  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);
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -566,6 +566,10 @@  static int alloc_proxy_bufs(struct ib_de
 			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;