提交 4a45b7d4 编写于 作者: B Bryan O'Sullivan 提交者: Linus Torvalds

[PATCH] IB/ipath: don't allow resources to be created with illegal values

Signed-off-by: NRobert Walsh <robert.walsh@qlogic.com>
Signed-off-by: NBryan O'Sullivan <bryan.osullivan@qlogic.com>
Cc: "Michael S. Tsirkin" <mst@mellanox.co.il>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 6665ddee
......@@ -170,6 +170,11 @@ struct ib_mr *ipath_reg_user_mr(struct ib_pd *pd, struct ib_umem *region,
int n, m, i;
struct ib_mr *ret;
if (region->length == 0) {
ret = ERR_PTR(-EINVAL);
goto bail;
}
n = 0;
list_for_each_entry(chunk, &region->chunk_list, list)
n += chunk->nents;
......
......@@ -667,6 +667,14 @@ struct ib_qp *ipath_create_qp(struct ib_pd *ibpd,
goto bail;
}
if (init_attr->cap.max_send_sge +
init_attr->cap.max_recv_sge +
init_attr->cap.max_send_wr +
init_attr->cap.max_recv_wr == 0) {
ret = ERR_PTR(-EINVAL);
goto bail;
}
switch (init_attr->qp_type) {
case IB_QPT_UC:
case IB_QPT_RC:
......
......@@ -792,6 +792,17 @@ static struct ib_ah *ipath_create_ah(struct ib_pd *pd,
goto bail;
}
if (ah_attr->dlid == 0) {
ret = ERR_PTR(-EINVAL);
goto bail;
}
if (ah_attr->port_num != 1 ||
ah_attr->port_num > pd->device->phys_port_cnt) {
ret = ERR_PTR(-EINVAL);
goto bail;
}
ah = kmalloc(sizeof *ah, GFP_ATOMIC);
if (!ah) {
ret = ERR_PTR(-ENOMEM);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册