Skip to content

Commit f93e91a

Browse files
ddalessajgunthorpe
authored andcommitted
RDMA/hfi1: Fix potential integer multiplication overflow errors
When multiplying of different types, an overflow is possible even when storing the result in a larger type. This is because the conversion is done after the multiplication. So arithmetic overflow and thus in incorrect value is possible. Correct an instance of this in the inter packet delay calculation. Fix by ensuring one of the operands is u64 which will promote the other to u64 as well ensuring no overflow. Cc: stable@vger.kernel.org Fixes: 7724105 ("IB/hfi1: add driver files") Link: https://lore.kernel.org/r/20220520183712.48973.29855.stgit@awfm-01.cornelisnetworks.com Reviewed-by: Mike Marciniszyn <mike.marciniszyn@cornelisnetworks.com> Signed-off-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent 629e052 commit f93e91a

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

  • drivers/infiniband/hw/hfi1

drivers/infiniband/hw/hfi1/init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ void set_link_ipg(struct hfi1_pportdata *ppd)
489489
u16 shift, mult;
490490
u64 src;
491491
u32 current_egress_rate; /* Mbits /sec */
492-
u32 max_pkt_time;
492+
u64 max_pkt_time;
493493
/*
494494
* max_pkt_time is the maximum packet egress time in units
495495
* of the fabric clock period 1/(805 MHz).

0 commit comments

Comments
 (0)