All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][next] RDMA/bnxt_re: fix sizeof mismatch for allocation of pbl_tbl.
@ 2020-10-06 11:47 ` Colin King
  0 siblings, 0 replies; 4+ messages in thread
From: Colin King @ 2020-10-06 11:47 UTC (permalink / raw)
  To: Selvin Xavier, Devesh Sharma, Somnath Kotur,
	Sriharsha Basavapatna, Naresh Kumar PBS, Doug Ledford,
	Jason Gunthorpe, Eddie Wai, linux-rdma
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

An incorrect sizeof is being used, u64 * is not correct, it should be
just u64 for a table of umem_pgs number of u64 items in the pbl_tbl.
Use the idiom sizeof(*pbl_tbl) to get the object type without the need
to explicitly use u64.

Addresses-Coverity: ("Sizeof not portable (SIZEOF_MISMATCH)")
Fixes: 1ac5a4047975 ("RDMA/bnxt_re: Add bnxt_re RoCE driver")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/infiniband/hw/bnxt_re/ib_verbs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
index a0e8d93595d8..dc7de0863c77 100644
--- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c
+++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
@@ -3856,7 +3856,7 @@ struct ib_mr *bnxt_re_reg_user_mr(struct ib_pd *ib_pd, u64 start, u64 length,
 	}
 
 	umem_pgs = ib_umem_num_dma_blocks(umem, page_size);
-	pbl_tbl = kcalloc(umem_pgs, sizeof(u64 *), GFP_KERNEL);
+	pbl_tbl = kcalloc(umem_pgs, sizeof(*pbl_tbl), GFP_KERNEL);
 	if (!pbl_tbl) {
 		rc = -ENOMEM;
 		goto free_umem;
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH][next] RDMA/bnxt_re: fix sizeof mismatch for allocation of pbl_tbl.
@ 2020-10-06 11:47 ` Colin King
  0 siblings, 0 replies; 4+ messages in thread
From: Colin King @ 2020-10-06 11:47 UTC (permalink / raw)
  To: Selvin Xavier, Devesh Sharma, Somnath Kotur,
	Sriharsha Basavapatna, Naresh Kumar PBS, Doug Ledford,
	Jason Gunthorpe, Eddie Wai, linux-rdma
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

An incorrect sizeof is being used, u64 * is not correct, it should be
just u64 for a table of umem_pgs number of u64 items in the pbl_tbl.
Use the idiom sizeof(*pbl_tbl) to get the object type without the need
to explicitly use u64.

Addresses-Coverity: ("Sizeof not portable (SIZEOF_MISMATCH)")
Fixes: 1ac5a4047975 ("RDMA/bnxt_re: Add bnxt_re RoCE driver")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/infiniband/hw/bnxt_re/ib_verbs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
index a0e8d93595d8..dc7de0863c77 100644
--- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c
+++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
@@ -3856,7 +3856,7 @@ struct ib_mr *bnxt_re_reg_user_mr(struct ib_pd *ib_pd, u64 start, u64 length,
 	}
 
 	umem_pgs = ib_umem_num_dma_blocks(umem, page_size);
-	pbl_tbl = kcalloc(umem_pgs, sizeof(u64 *), GFP_KERNEL);
+	pbl_tbl = kcalloc(umem_pgs, sizeof(*pbl_tbl), GFP_KERNEL);
 	if (!pbl_tbl) {
 		rc = -ENOMEM;
 		goto free_umem;
-- 
2.27.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH][next] RDMA/bnxt_re: fix sizeof mismatch for allocation of pbl_tbl.
  2020-10-06 11:47 ` Colin King
@ 2020-10-06 19:57   ` Jason Gunthorpe
  -1 siblings, 0 replies; 4+ messages in thread
From: Jason Gunthorpe @ 2020-10-06 19:57 UTC (permalink / raw)
  To: Colin King
  Cc: Selvin Xavier, Devesh Sharma, Somnath Kotur,
	Sriharsha Basavapatna, Naresh Kumar PBS, Doug Ledford, Eddie Wai,
	linux-rdma, kernel-janitors, linux-kernel

On Tue, Oct 06, 2020 at 12:47:00PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> An incorrect sizeof is being used, u64 * is not correct, it should be
> just u64 for a table of umem_pgs number of u64 items in the pbl_tbl.
> Use the idiom sizeof(*pbl_tbl) to get the object type without the need
> to explicitly use u64.
> 
> Addresses-Coverity: ("Sizeof not portable (SIZEOF_MISMATCH)")
> Fixes: 1ac5a4047975 ("RDMA/bnxt_re: Add bnxt_re RoCE driver")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/infiniband/hw/bnxt_re/ib_verbs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied to for-next, thanks

Jason

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH][next] RDMA/bnxt_re: fix sizeof mismatch for allocation of pbl_tbl.
@ 2020-10-06 19:57   ` Jason Gunthorpe
  0 siblings, 0 replies; 4+ messages in thread
From: Jason Gunthorpe @ 2020-10-06 19:57 UTC (permalink / raw)
  To: Colin King
  Cc: Selvin Xavier, Devesh Sharma, Somnath Kotur,
	Sriharsha Basavapatna, Naresh Kumar PBS, Doug Ledford, Eddie Wai,
	linux-rdma, kernel-janitors, linux-kernel

On Tue, Oct 06, 2020 at 12:47:00PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> An incorrect sizeof is being used, u64 * is not correct, it should be
> just u64 for a table of umem_pgs number of u64 items in the pbl_tbl.
> Use the idiom sizeof(*pbl_tbl) to get the object type without the need
> to explicitly use u64.
> 
> Addresses-Coverity: ("Sizeof not portable (SIZEOF_MISMATCH)")
> Fixes: 1ac5a4047975 ("RDMA/bnxt_re: Add bnxt_re RoCE driver")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/infiniband/hw/bnxt_re/ib_verbs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied to for-next, thanks

Jason

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-10-06 19:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-06 11:47 [PATCH][next] RDMA/bnxt_re: fix sizeof mismatch for allocation of pbl_tbl Colin King
2020-10-06 11:47 ` Colin King
2020-10-06 19:57 ` Jason Gunthorpe
2020-10-06 19:57   ` Jason Gunthorpe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.