diff mbox series

[06/12] net/ice: fix build with GCC 12

Message ID 20220518101657.1230416-7-david.marchand@redhat.com (mailing list archive)
State Accepted
Delegated to: Thomas Monjalon
Headers show
Series Fix compilation with gcc 12 | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

David Marchand May 18, 2022, 10:16 a.m. UTC
GCC 12 raises the following warning:

In file included from ../lib/mempool/rte_mempool.h:46,
                 from ../lib/mbuf/rte_mbuf.h:38,
                 from ../lib/net/rte_ether.h:22,
                 from ../lib/ethdev/rte_ethdev.h:172,
                 from ../lib/ethdev/ethdev_driver.h:22,
                 from ../lib/ethdev/ethdev_pci.h:17,
                 from ../drivers/net/ice/ice_ethdev.c:6:
../drivers/net/ice/ice_ethdev.c: In function ‘ice_dev_configure’:
../lib/eal/x86/include/rte_memcpy.h:370:9: warning: array subscript 64 is
        outside array bounds of ‘struct ice_aqc_get_set_rss_keys[1]’
        [-Warray-bounds]
  370 | rte_mov32((uint8_t *)dst + 2 * 32, (const uint8_t *)src + 2 * 32);
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/net/ice/ice_ethdev.c:3202:41: note: while referencing ‘key’
 3202 |         struct ice_aqc_get_set_rss_keys key;
      |                                         ^~~

Restrict copy to minimum size.

Cc: stable@dpdk.org

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 drivers/net/ice/ice_ethdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Stephen Hemminger June 11, 2022, 3:36 p.m. UTC | #1
On Wed, 18 May 2022 12:16:51 +0200
David Marchand <david.marchand@redhat.com> wrote:

> GCC 12 raises the following warning:
> 
> In file included from ../lib/mempool/rte_mempool.h:46,
>                  from ../lib/mbuf/rte_mbuf.h:38,
>                  from ../lib/net/rte_ether.h:22,
>                  from ../lib/ethdev/rte_ethdev.h:172,
>                  from ../lib/ethdev/ethdev_driver.h:22,
>                  from ../lib/ethdev/ethdev_pci.h:17,
>                  from ../drivers/net/ice/ice_ethdev.c:6:
> ../drivers/net/ice/ice_ethdev.c: In function ‘ice_dev_configure’:
> ../lib/eal/x86/include/rte_memcpy.h:370:9: warning: array subscript 64 is
>         outside array bounds of ‘struct ice_aqc_get_set_rss_keys[1]’
>         [-Warray-bounds]
>   370 | rte_mov32((uint8_t *)dst + 2 * 32, (const uint8_t *)src + 2 * 32);
>       | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ../drivers/net/ice/ice_ethdev.c:3202:41: note: while referencing ‘key’
>  3202 |         struct ice_aqc_get_set_rss_keys key;
>       |                                         ^~~
> 
> Restrict copy to minimum size.
> 
> Cc: stable@dpdk.org
> 
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---

Acked-by: Stephen Hemminger <stephen@networkplumber.org>
diff mbox series

Patch

diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 00ac2bb191..d69d480268 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -3263,7 +3263,8 @@  static int ice_init_rss(struct ice_pf *pf)
 			   RTE_MIN(rss_conf->rss_key_len,
 				   vsi->rss_key_size));
 
-	rte_memcpy(key.standard_rss_key, vsi->rss_key, vsi->rss_key_size);
+	rte_memcpy(key.standard_rss_key, vsi->rss_key,
+		RTE_MIN(sizeof(key.standard_rss_key), vsi->rss_key_size));
 	ret = ice_aq_set_rss_key(hw, vsi->idx, &key);
 	if (ret)
 		goto out;