Skip to content

Commit

Permalink
RDMA/mana_ib: Use safer allocation function()
Browse files Browse the repository at this point in the history
My static checker says this multiplication can overflow.  I'm not an
expert in this code but the call tree would be:

ib_uverbs_handler_UVERBS_METHOD_QP_CREATE() <- reads cap from the user
-> ib_create_qp_user()
   -> create_qp()
      -> mana_ib_create_qp()
         -> mana_ib_create_ud_qp()
            -> create_shadow_queue()

It can't hurt to use safer interfaces.

Fixes: c8017f5 ("RDMA/mana_ib: UD/GSI work requests")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://patch.msgid.link/58439ac0-1ee5-4f96-a595-7ab83b59139b@stanley.mountain
Reviewed-by: Long Li <longli@microsoft.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
  • Loading branch information
Dan Carpenter authored and Leon Romanovsky committed Mar 8, 2025
1 parent 98cf1d1 commit 1d5c695
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/infiniband/hw/mana/shadow_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct shadow_queue {

static inline int create_shadow_queue(struct shadow_queue *queue, uint32_t length, uint32_t stride)
{
queue->buffer = kvmalloc(length * stride, GFP_KERNEL);
queue->buffer = kvmalloc_array(length, stride, GFP_KERNEL);
if (!queue->buffer)
return -ENOMEM;

Expand Down

0 comments on commit 1d5c695

Please sign in to comment.