Commit 7ef75875 authored by Colin Ian King's avatar Colin Ian King Committed by Jason Gunthorpe

RDMA/hns: fix potential integer overflow on left shift

There is a potential integer overflow when int i is left shifted as this
is evaluated using 32 bit arithmetic but is being used in a context that
expects an expression of type dma_addr_t.  Fix this by casting integer i
to dma_addr_t before shifting to avoid the overflow.

Addresses-Coverity: ("Unintentional integer overflow")
Fixes: 2ac0bc5e ("RDMA/hns: Add a group interfaces for optimizing buffers getting flow")
Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 7796d2a3
...@@ -257,7 +257,7 @@ int hns_roce_get_kmem_bufs(struct hns_roce_dev *hr_dev, dma_addr_t *bufs, ...@@ -257,7 +257,7 @@ int hns_roce_get_kmem_bufs(struct hns_roce_dev *hr_dev, dma_addr_t *bufs,
for (i = start; i < end; i++) for (i = start; i < end; i++)
if (buf->nbufs == 1) if (buf->nbufs == 1)
bufs[total++] = buf->direct.map + bufs[total++] = buf->direct.map +
(i << buf->page_shift); ((dma_addr_t)i << buf->page_shift);
else else
bufs[total++] = buf->page_list[i].map; bufs[total++] = buf->page_list[i].map;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment