Skip to content

Commit 8e71f69

Browse files
Colin Ian Kingjgunthorpe
authored andcommitted
IB/rdmavt: Fix sizeof mismatch
An incorrect sizeof is being used, struct rvt_ibport ** is not correct, it should be struct rvt_ibport *. Note that since ** is the same size as * this is not causing any issues. Improve this fix by using sizeof(*rdi->ports) as this allows us to not even reference the type of the pointer. Also remove line breaks as the entire statement can fit on one line. Link: https://lore.kernel.org/r/20201008095204.82683-1-colin.king@canonical.com Addresses-Coverity: ("Sizeof not portable (SIZEOF_MISMATCH)") Fixes: ff6acd6 ("IB/rdmavt: Add device structure allocation") Signed-off-by: Colin Ian King <colin.king@canonical.com> Reviewed-by: Ira Weiny <ira.weiny@intel.com> Acked-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent 6c111ba commit 8e71f69

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

  • drivers/infiniband/sw/rdmavt

drivers/infiniband/sw/rdmavt/vt.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,7 @@ struct rvt_dev_info *rvt_alloc_device(size_t size, int nports)
9595
if (!rdi)
9696
return rdi;
9797

98-
rdi->ports = kcalloc(nports,
99-
sizeof(struct rvt_ibport **),
100-
GFP_KERNEL);
98+
rdi->ports = kcalloc(nports, sizeof(*rdi->ports), GFP_KERNEL);
10199
if (!rdi->ports)
102100
ib_dealloc_device(&rdi->ibdev);
103101

0 commit comments

Comments
 (0)