* [PATCH] net: prestera: replace zero-length array with flexible-array member
@ 2021-12-04 17:13 José Expósito
2021-12-04 17:38 ` Volodymyr Mytnyk
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: José Expósito @ 2021-12-04 17:13 UTC (permalink / raw)
To: tchornyi
Cc: davem, kuba, netdev, linux-kernel, linux-hardening,
kernel-hardening, gustavoars, José Expósito
One-element and zero-length arrays are deprecated and should be
replaced with flexible-array members:
https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays
Replace zero-length array with flexible-array member and make use
of the struct_size() helper.
Link: https://github.com/KSPP/linux/issues/78
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
---
drivers/net/ethernet/marvell/prestera/prestera_hw.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/marvell/prestera/prestera_hw.c b/drivers/net/ethernet/marvell/prestera/prestera_hw.c
index 92cb5e9099c6..6282c9822e2b 100644
--- a/drivers/net/ethernet/marvell/prestera/prestera_hw.c
+++ b/drivers/net/ethernet/marvell/prestera/prestera_hw.c
@@ -443,7 +443,7 @@ struct prestera_msg_counter_resp {
__le32 offset;
__le32 num_counters;
__le32 done;
- struct prestera_msg_counter_stats stats[0];
+ struct prestera_msg_counter_stats stats[];
};
struct prestera_msg_span_req {
@@ -1900,7 +1900,7 @@ int prestera_hw_counters_get(struct prestera_switch *sw, u32 idx,
.block_id = __cpu_to_le32(idx),
.num_counters = __cpu_to_le32(*len),
};
- size_t size = sizeof(*resp) + sizeof(*resp->stats) * (*len);
+ size_t size = struct_size(resp, stats, *len);
int err, i;
resp = kmalloc(size, GFP_KERNEL);
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] net: prestera: replace zero-length array with flexible-array member
2021-12-04 17:13 [PATCH] net: prestera: replace zero-length array with flexible-array member José Expósito
@ 2021-12-04 17:38 ` Volodymyr Mytnyk
2021-12-06 16:50 ` Gustavo A. R. Silva
2021-12-07 0:40 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Volodymyr Mytnyk @ 2021-12-04 17:38 UTC (permalink / raw)
To: José Expósito, tchornyi
Cc: davem, kuba, netdev, linux-kernel, linux-hardening,
kernel-hardening, gustavoars
> Subject: [PATCH] net: prestera: replace zero-length array with flexible-array member
>
> One-element and zero-length arrays are deprecated and should be
> replaced with flexible-array members:
> https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays
>
> Replace zero-length array with flexible-array member and make use
> of the struct_size() helper.
>
> Link: https://github.com/KSPP/linux/issues/78
> Signed-off-by: Jose Exposito <jose.exposito89@gmail.com>
> ---
> drivers/net/ethernet/marvell/prestera/prestera_hw.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/marvell/prestera/prestera_hw.c b/drivers/net/ethernet/marvell/prestera/prestera_hw.c
> index 92cb5e9099c6..6282c9822e2b 100644
> --- a/drivers/net/ethernet/marvell/prestera/prestera_hw.c
> +++ b/drivers/net/ethernet/marvell/prestera/prestera_hw.c
> @@ -443,7 +443,7 @@ struct prestera_msg_counter_resp {
> __le32 offset;
> __le32 num_counters;
> __le32 done;
> - struct prestera_msg_counter_stats stats[0];
> + struct prestera_msg_counter_stats stats[];
> };
>
> struct prestera_msg_span_req {
> @@ -1900,7 +1900,7 @@ int prestera_hw_counters_get(struct prestera_switch *sw, u32 idx,
> .block_id = __cpu_to_le32(idx),
> .num_counters = __cpu_to_le32(*len),
> };
> - size_t size = sizeof(*resp) + sizeof(*resp->stats) * (*len);
> + size_t size = struct_size(resp, stats, *len);
> int err, i;
>
> resp = kmalloc(size, GFP_KERNEL);
> --
> 2.25.1
Thanks.
Reviewed-by: Volodymyr Mytnyk <vmytnyk@marvell.com>
Tested-by: Volodymyr Mytnyk <vmytnyk@marvell.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net: prestera: replace zero-length array with flexible-array member
2021-12-04 17:13 [PATCH] net: prestera: replace zero-length array with flexible-array member José Expósito
2021-12-04 17:38 ` Volodymyr Mytnyk
@ 2021-12-06 16:50 ` Gustavo A. R. Silva
2021-12-07 0:40 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Gustavo A. R. Silva @ 2021-12-06 16:50 UTC (permalink / raw)
To: José Expósito
Cc: tchornyi, davem, kuba, netdev, linux-kernel, linux-hardening,
kernel-hardening
On Sat, Dec 04, 2021 at 06:13:49PM +0100, José Expósito wrote:
> One-element and zero-length arrays are deprecated and should be
> replaced with flexible-array members:
> https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays
>
> Replace zero-length array with flexible-array member and make use
> of the struct_size() helper.
>
> Link: https://github.com/KSPP/linux/issues/78
> Signed-off-by: José Expósito <jose.exposito89@gmail.com>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Thanks
--
Gustavo
> ---
> drivers/net/ethernet/marvell/prestera/prestera_hw.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/marvell/prestera/prestera_hw.c b/drivers/net/ethernet/marvell/prestera/prestera_hw.c
> index 92cb5e9099c6..6282c9822e2b 100644
> --- a/drivers/net/ethernet/marvell/prestera/prestera_hw.c
> +++ b/drivers/net/ethernet/marvell/prestera/prestera_hw.c
> @@ -443,7 +443,7 @@ struct prestera_msg_counter_resp {
> __le32 offset;
> __le32 num_counters;
> __le32 done;
> - struct prestera_msg_counter_stats stats[0];
> + struct prestera_msg_counter_stats stats[];
> };
>
> struct prestera_msg_span_req {
> @@ -1900,7 +1900,7 @@ int prestera_hw_counters_get(struct prestera_switch *sw, u32 idx,
> .block_id = __cpu_to_le32(idx),
> .num_counters = __cpu_to_le32(*len),
> };
> - size_t size = sizeof(*resp) + sizeof(*resp->stats) * (*len);
> + size_t size = struct_size(resp, stats, *len);
> int err, i;
>
> resp = kmalloc(size, GFP_KERNEL);
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net: prestera: replace zero-length array with flexible-array member
2021-12-04 17:13 [PATCH] net: prestera: replace zero-length array with flexible-array member José Expósito
2021-12-04 17:38 ` Volodymyr Mytnyk
2021-12-06 16:50 ` Gustavo A. R. Silva
@ 2021-12-07 0:40 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-12-07 0:40 UTC (permalink / raw)
To: =?utf-8?b?Sm9zw6kgRXhww7NzaXRvIDxqb3NlLmV4cG9zaXRvODlAZ21haWwuY29tPg==?=
Cc: tchornyi, davem, kuba, netdev, linux-kernel, linux-hardening,
kernel-hardening, gustavoars
Hello:
This patch was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:
On Sat, 4 Dec 2021 18:13:49 +0100 you wrote:
> One-element and zero-length arrays are deprecated and should be
> replaced with flexible-array members:
> https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays
>
> Replace zero-length array with flexible-array member and make use
> of the struct_size() helper.
>
> [...]
Here is the summary with links:
- net: prestera: replace zero-length array with flexible-array member
https://git.kernel.org/netdev/net-next/c/01081be1ea8c
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-12-07 12:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-04 17:13 [PATCH] net: prestera: replace zero-length array with flexible-array member José Expósito
2021-12-04 17:38 ` Volodymyr Mytnyk
2021-12-06 16:50 ` Gustavo A. R. Silva
2021-12-07 0:40 ` patchwork-bot+netdevbpf
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).