Skip to content

Commit 563ca0e

Browse files
error27rleon
authored andcommitted
RDMA/mana_ib: Prevent array underflow in mana_ib_create_qp_raw()
The "port" comes from the user and if it is zero then the: ndev = mc->ports[port - 1]; assignment does an out of bounds read. I have changed the if statement to fix this and to mirror how it is done in mana_ib_create_qp_rss(). Fixes: 0266a17 ("RDMA/mana_ib: Add a driver for Microsoft Azure Network Adapter") Signed-off-by: Dan Carpenter <[email protected]> Link: https://lore.kernel.org/r/Y8/3Vn8qx00kE9Kk@kili Acked-by: Long Li <[email protected]> Signed-off-by: Leon Romanovsky <[email protected]>
1 parent f9c47b2 commit 563ca0e

File tree

1 file changed

+1
-1
lines changed
  • drivers/infiniband/hw/mana

1 file changed

+1
-1
lines changed

drivers/infiniband/hw/mana/qp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ static int mana_ib_create_qp_raw(struct ib_qp *ibqp, struct ib_pd *ibpd,
289289

290290
/* IB ports start with 1, MANA Ethernet ports start with 0 */
291291
port = ucmd.port;
292-
if (ucmd.port > mc->num_ports)
292+
if (port < 1 || port > mc->num_ports)
293293
return -EINVAL;
294294

295295
if (attr->cap.max_send_wr > MAX_SEND_BUFFERS_PER_QUEUE) {

0 commit comments

Comments
 (0)