From: Dan Carpenter Date: Thu, 6 Mar 2025 19:49:06 +0000 (+0300) Subject: RDMA/mana_ib: Use safer allocation function() X-Git-Tag: block-6.15-20250403~37^2~28 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=1d5c69514e742846ad3b8727b51b1fd46ea251fd;p=linux-block.git RDMA/mana_ib: Use safer allocation function() 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: c8017f5b4856 ("RDMA/mana_ib: UD/GSI work requests") Signed-off-by: Dan Carpenter Link: https://patch.msgid.link/58439ac0-1ee5-4f96-a595-7ab83b59139b@stanley.mountain Reviewed-by: Long Li Signed-off-by: Leon Romanovsky --- diff --git a/drivers/infiniband/hw/mana/shadow_queue.h b/drivers/infiniband/hw/mana/shadow_queue.h index d8bfb4c712d5..a4b3818f9c39 100644 --- a/drivers/infiniband/hw/mana/shadow_queue.h +++ b/drivers/infiniband/hw/mana/shadow_queue.h @@ -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;