2024-05-19 07:37:06

by Christophe JAILLET

[permalink] [raw]
Subject: [PATCH] RDMA/irdma: Annotate flexible array with __counted_by() in struct irdma_qvlist_info

'num_vectors' is used to count the number of elements in the 'qv_info'
flexible array in "struct irdma_qvlist_info".

So annotate it with __counted_by() to make it explicit and enable some
additional checks.

This allocation is done in irdma_save_msix_info().

Signed-off-by: Christophe JAILLET <[email protected]>
---
drivers/infiniband/hw/irdma/main.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/irdma/main.h b/drivers/infiniband/hw/irdma/main.h
index b65bc2ea542f..9f0ed6e84471 100644
--- a/drivers/infiniband/hw/irdma/main.h
+++ b/drivers/infiniband/hw/irdma/main.h
@@ -239,7 +239,7 @@ struct irdma_qv_info {

struct irdma_qvlist_info {
u32 num_vectors;
- struct irdma_qv_info qv_info[];
+ struct irdma_qv_info qv_info[] __counted_by(num_vectors);
};

struct irdma_gen_ops {
--
2.45.1



2024-05-20 15:02:47

by Saleem, Shiraz

[permalink] [raw]
Subject: RE: [PATCH] RDMA/irdma: Annotate flexible array with __counted_by() in struct irdma_qvlist_info

> Subject: [PATCH] RDMA/irdma: Annotate flexible array with __counted_by() in
> struct irdma_qvlist_info
>
> 'num_vectors' is used to count the number of elements in the 'qv_info'
> flexible array in "struct irdma_qvlist_info".
>
> So annotate it with __counted_by() to make it explicit and enable some
> additional checks.
>
> This allocation is done in irdma_save_msix_info().
>
> Signed-off-by: Christophe JAILLET <[email protected]>
> ---
> drivers/infiniband/hw/irdma/main.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/infiniband/hw/irdma/main.h
> b/drivers/infiniband/hw/irdma/main.h
> index b65bc2ea542f..9f0ed6e84471 100644
> --- a/drivers/infiniband/hw/irdma/main.h
> +++ b/drivers/infiniband/hw/irdma/main.h
> @@ -239,7 +239,7 @@ struct irdma_qv_info {
>
> struct irdma_qvlist_info {
> u32 num_vectors;
> - struct irdma_qv_info qv_info[];
> + struct irdma_qv_info qv_info[] __counted_by(num_vectors);
> };

Acked-by: Shiraz Saleem <[email protected]>

2024-05-30 14:27:34

by Leon Romanovsky

[permalink] [raw]
Subject: Re: [PATCH] RDMA/irdma: Annotate flexible array with __counted_by() in struct irdma_qvlist_info


On Sun, 19 May 2024 09:02:15 +0200, Christophe JAILLET wrote:
> 'num_vectors' is used to count the number of elements in the 'qv_info'
> flexible array in "struct irdma_qvlist_info".
>
> So annotate it with __counted_by() to make it explicit and enable some
> additional checks.
>
> This allocation is done in irdma_save_msix_info().
>
> [...]

Applied, thanks!

[1/1] RDMA/irdma: Annotate flexible array with __counted_by() in struct irdma_qvlist_info
https://git.kernel.org/rdma/rdma/c/38c02d813aa321

Best regards,
--
Leon Romanovsky <[email protected]>