* [PATCH] IB/rdmavt: Fix sizeof mismatch
@ 2020-10-08 9:52 Colin King
2020-10-08 16:41 ` Ira Weiny
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Colin King @ 2020-10-08 9:52 UTC (permalink / raw)
To: Dennis Dalessandro, Mike Marciniszyn, Doug Ledford,
Jason Gunthorpe, Ira Weiny, linux-rdma
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
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.
Addresses-Coverity: ("Sizeof not portable (SIZEOF_MISMATCH)")
Fixes: ff6acd69518e ("IB/rdmavt: Add device structure allocation")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/infiniband/sw/rdmavt/vt.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/infiniband/sw/rdmavt/vt.c b/drivers/infiniband/sw/rdmavt/vt.c
index f904bb34477a..2d534c450f3c 100644
--- a/drivers/infiniband/sw/rdmavt/vt.c
+++ b/drivers/infiniband/sw/rdmavt/vt.c
@@ -95,9 +95,7 @@ struct rvt_dev_info *rvt_alloc_device(size_t size, int nports)
if (!rdi)
return rdi;
- rdi->ports = kcalloc(nports,
- sizeof(struct rvt_ibport **),
- GFP_KERNEL);
+ rdi->ports = kcalloc(nports, sizeof(*rdi->ports), GFP_KERNEL);
if (!rdi->ports)
ib_dealloc_device(&rdi->ibdev);
--
2.27.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] IB/rdmavt: Fix sizeof mismatch
2020-10-08 9:52 [PATCH] IB/rdmavt: Fix sizeof mismatch Colin King
@ 2020-10-08 16:41 ` Ira Weiny
2020-10-08 17:21 ` dennis.dalessandro
2020-10-08 18:18 ` Jason Gunthorpe
2 siblings, 0 replies; 4+ messages in thread
From: Ira Weiny @ 2020-10-08 16:41 UTC (permalink / raw)
To: Colin King
Cc: Dennis Dalessandro, Mike Marciniszyn, Doug Ledford,
Jason Gunthorpe, linux-rdma, kernel-janitors, linux-kernel
On Thu, Oct 08, 2020 at 10:52:04AM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> 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.
>
> Addresses-Coverity: ("Sizeof not portable (SIZEOF_MISMATCH)")
> Fixes: ff6acd69518e ("IB/rdmavt: Add device structure allocation")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
> ---
> drivers/infiniband/sw/rdmavt/vt.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/infiniband/sw/rdmavt/vt.c b/drivers/infiniband/sw/rdmavt/vt.c
> index f904bb34477a..2d534c450f3c 100644
> --- a/drivers/infiniband/sw/rdmavt/vt.c
> +++ b/drivers/infiniband/sw/rdmavt/vt.c
> @@ -95,9 +95,7 @@ struct rvt_dev_info *rvt_alloc_device(size_t size, int nports)
> if (!rdi)
> return rdi;
>
> - rdi->ports = kcalloc(nports,
> - sizeof(struct rvt_ibport **),
> - GFP_KERNEL);
> + rdi->ports = kcalloc(nports, sizeof(*rdi->ports), GFP_KERNEL);
> if (!rdi->ports)
> ib_dealloc_device(&rdi->ibdev);
>
> --
> 2.27.0
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] IB/rdmavt: Fix sizeof mismatch
2020-10-08 9:52 [PATCH] IB/rdmavt: Fix sizeof mismatch Colin King
2020-10-08 16:41 ` Ira Weiny
@ 2020-10-08 17:21 ` dennis.dalessandro
2020-10-08 18:18 ` Jason Gunthorpe
2 siblings, 0 replies; 4+ messages in thread
From: dennis.dalessandro @ 2020-10-08 17:21 UTC (permalink / raw)
To: Colin King
Cc: Dennis Dalessandro, Mike Marciniszyn, Doug Ledford,
Jason Gunthorpe, Ira Weiny, linux-rdma, kernel-janitors,
linux-kernel
On 2020-10-08 05:52, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> 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.
>
> Addresses-Coverity: ("Sizeof not portable (SIZEOF_MISMATCH)")
> Fixes: ff6acd69518e ("IB/rdmavt: Add device structure allocation")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/infiniband/sw/rdmavt/vt.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/infiniband/sw/rdmavt/vt.c
> b/drivers/infiniband/sw/rdmavt/vt.c
> index f904bb34477a..2d534c450f3c 100644
> --- a/drivers/infiniband/sw/rdmavt/vt.c
> +++ b/drivers/infiniband/sw/rdmavt/vt.c
> @@ -95,9 +95,7 @@ struct rvt_dev_info *rvt_alloc_device(size_t size,
> int nports)
> if (!rdi)
> return rdi;
>
> - rdi->ports = kcalloc(nports,
> - sizeof(struct rvt_ibport **),
> - GFP_KERNEL);
> + rdi->ports = kcalloc(nports, sizeof(*rdi->ports), GFP_KERNEL);
> if (!rdi->ports)
> ib_dealloc_device(&rdi->ibdev);
Acked-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] IB/rdmavt: Fix sizeof mismatch
2020-10-08 9:52 [PATCH] IB/rdmavt: Fix sizeof mismatch Colin King
2020-10-08 16:41 ` Ira Weiny
2020-10-08 17:21 ` dennis.dalessandro
@ 2020-10-08 18:18 ` Jason Gunthorpe
2 siblings, 0 replies; 4+ messages in thread
From: Jason Gunthorpe @ 2020-10-08 18:18 UTC (permalink / raw)
To: Colin King
Cc: Dennis Dalessandro, Mike Marciniszyn, Doug Ledford, Ira Weiny,
linux-rdma, kernel-janitors, linux-kernel
On Thu, Oct 08, 2020 at 10:52:04AM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> 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.
>
> Addresses-Coverity: ("Sizeof not portable (SIZEOF_MISMATCH)")
> Fixes: ff6acd69518e ("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>
> ---
> drivers/infiniband/sw/rdmavt/vt.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
Applied to for-next, thanks
Jason
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-10-08 18:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-08 9:52 [PATCH] IB/rdmavt: Fix sizeof mismatch Colin King
2020-10-08 16:41 ` Ira Weiny
2020-10-08 17:21 ` dennis.dalessandro
2020-10-08 18:18 ` Jason Gunthorpe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).