Skip to content

Commit 859976d

Browse files
Dan Carpenterrolandd
authored andcommitted
RDMA/amso1100: Check for integer overflow in c2_alloc_cq_buf()
This is a static checker fix. The static checker says that q_size comes from the user and can be any 32 bit value. The call tree is: --> ib_uverbs_create_cq() --> c2_create_cq() --> c2_init_cq() Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Doug Ledford <dledford@redhat.com> Signed-off-by: Roland Dreier <roland@purestorage.com>
1 parent 64aa90f commit 859976d

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

  • drivers/infiniband/hw/amso1100

‎drivers/infiniband/hw/amso1100/c2_cq.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,14 @@ static void c2_free_cq_buf(struct c2_dev *c2dev, struct c2_mq *mq)
260260
mq->msg_pool.host, dma_unmap_addr(mq, mapping));
261261
}
262262

263-
static int c2_alloc_cq_buf(struct c2_dev *c2dev, struct c2_mq *mq, int q_size,
264-
int msg_size)
263+
static int c2_alloc_cq_buf(struct c2_dev *c2dev, struct c2_mq *mq,
264+
size_t q_size, size_t msg_size)
265265
{
266266
u8 *pool_start;
267267

268+
if (q_size > SIZE_MAX / msg_size)
269+
return -EINVAL;
270+
268271
pool_start = dma_alloc_coherent(&c2dev->pcidev->dev, q_size * msg_size,
269272
&mq->host_dma, GFP_KERNEL);
270273
if (!pool_start)

0 commit comments

Comments
 (0)