[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <VI1P190MB07344B3C160E9A73165422A28F6B9@VI1P190MB0734.EURP190.PROD.OUTLOOK.COM>
Date: Sat, 4 Dec 2021 17:38:21 +0000
From: Volodymyr Mytnyk <volodymyr.mytnyk@...ision.eu>
To: José Expósito <jose.exposito89@...il.com>,
"tchornyi@...vell.com" <tchornyi@...vell.com>
CC: "davem@...emloft.net" <davem@...emloft.net>,
"kuba@...nel.org" <kuba@...nel.org>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-hardening@...r.kernel.org" <linux-hardening@...r.kernel.org>,
"kernel-hardening@...ts.openwall.com"
<kernel-hardening@...ts.openwall.com>,
"gustavoars@...nel.org" <gustavoars@...nel.org>
Subject: Re: [PATCH] net: prestera: replace zero-length array with
flexible-array member
> 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@...il.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@...vell.com>
Tested-by: Volodymyr Mytnyk <vmytnyk@...vell.com>
Powered by blists - more mailing lists