* [PATCH][next] net: thunderx: Use struct_size() helper in kmalloc()
@ 2020-10-08 14:28 Gustavo A. R. Silva
2020-10-10 17:36 ` Jakub Kicinski
0 siblings, 1 reply; 2+ messages in thread
From: Gustavo A. R. Silva @ 2020-10-08 14:28 UTC (permalink / raw)
To: Sunil Goutham, David S. Miller, Jakub Kicinski
Cc: netdev, linux-hardening, linux-kernel, linux-arm-kernel,
Gustavo A. R. Silva
Make use of the new struct_size() helper instead of the offsetof() idiom.
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
drivers/net/ethernet/cavium/thunder/nicvf_main.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_main.c b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
index 0a94c396173b..f3b7b443f964 100644
--- a/drivers/net/ethernet/cavium/thunder/nicvf_main.c
+++ b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
@@ -2065,8 +2065,8 @@ static void nicvf_set_rx_mode(struct net_device *netdev)
mode |= BGX_XCAST_MCAST_FILTER;
/* here we need to copy mc addrs */
if (netdev_mc_count(netdev)) {
- mc_list = kmalloc(offsetof(typeof(*mc_list),
- mc[netdev_mc_count(netdev)]),
+ mc_list = kmalloc(struct_size(mc_list, mc,
+ netdev_mc_count(netdev)),
GFP_ATOMIC);
if (unlikely(!mc_list))
return;
--
2.27.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH][next] net: thunderx: Use struct_size() helper in kmalloc()
2020-10-08 14:28 [PATCH][next] net: thunderx: Use struct_size() helper in kmalloc() Gustavo A. R. Silva
@ 2020-10-10 17:36 ` Jakub Kicinski
0 siblings, 0 replies; 2+ messages in thread
From: Jakub Kicinski @ 2020-10-10 17:36 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: Sunil Goutham, netdev, linux-kernel, linux-hardening,
David S. Miller, linux-arm-kernel
On Thu, 8 Oct 2020 09:28:06 -0500 Gustavo A. R. Silva wrote:
> Make use of the new struct_size() helper instead of the offsetof() idiom.
>
> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Applied, thanks!
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-10-10 17:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-08 14:28 [PATCH][next] net: thunderx: Use struct_size() helper in kmalloc() Gustavo A. R. Silva
2020-10-10 17:36 ` Jakub Kicinski
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).