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/[email protected] Addresses-Coverity: ("Sizeof not portable (SIZEOF_MISMATCH)") Fixes: ff6acd6 ("IB/rdmavt: Add device structure allocation") Signed-off-by: Colin Ian King <[email protected]> Reviewed-by: Ira Weiny <[email protected]> Acked-by: Dennis Dalessandro <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 6c111ba commit 8e71f69

File tree

1 file changed

+1
-3
lines changed
  • drivers/infiniband/sw/rdmavt

1 file changed

+1
-3
lines changed

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)