diff mbox series

[ovs-dev,2/2] netdev-linux: Fix ethtool_cmd is partly outside array bounds.

Message ID 20240527110033.531720-2-roid@nvidia.com
State Accepted
Commit ce1663b5fe4fae839bd0d20736d5dceae5650f7d
Headers show
Series [ovs-dev,1/2] netdev-linux: Fix using uninitialized current_speed. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/intel-ovs-compilation success test: success

Commit Message

Roi Dayan May 27, 2024, 11 a.m. UTC
Used Ubuntu with gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0

lib/netdev-linux.c: In function ‘netdev_linux_construct’:
lib/netdev-linux.c:7003:15: error: array subscript ‘struct ethtool_cmd[0]’ is partly outside array bounds of ‘union <anonymous>[1]’ [-Werror=array-bounds]
 7003 |     ecmd->cmd = cmd;
      |     ~~~~~~~~~~^~~~~
lib/netdev-linux.c:2411:7: note: while referencing ‘sset_info’
 2411 |     } sset_info;
      |       ^~~~~~~~~

Fixes: 6c59c195266c ("netdev-linux: Use ethtool to detect offload support.")
Signed-off-by: Roi Dayan <roid@nvidia.com>
---
 lib/netdev-linux.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Ilya Maximets May 28, 2024, 8:30 p.m. UTC | #1
On 5/27/24 13:00, Roi Dayan via dev wrote:
> Used Ubuntu with gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0
> 
> lib/netdev-linux.c: In function ‘netdev_linux_construct’:
> lib/netdev-linux.c:7003:15: error: array subscript ‘struct ethtool_cmd[0]’ is partly outside array bounds of ‘union <anonymous>[1]’ [-Werror=array-bounds]
>  7003 |     ecmd->cmd = cmd;
>       |     ~~~~~~~~~~^~~~~
> lib/netdev-linux.c:2411:7: note: while referencing ‘sset_info’
>  2411 |     } sset_info;
>       |       ^~~~~~~~~
> 
> Fixes: 6c59c195266c ("netdev-linux: Use ethtool to detect offload support.")
> Signed-off-by: Roi Dayan <roid@nvidia.com>
> ---
>  lib/netdev-linux.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
> index 0cb379295af1..ec6fcf7b2c6a 100644
> --- a/lib/netdev-linux.c
> +++ b/lib/netdev-linux.c
> @@ -2402,6 +2402,7 @@ static int
>  netdev_linux_read_stringset_info(struct netdev_linux *netdev, uint32_t *len)
>  {
>      union {
> +        struct ethtool_cmd ecmd;
>          struct ethtool_sset_info hdr;
>          struct {
>              uint64_t pad[2];

We need to migrate from the legacy ethtool_cmd API at some point,
but this change makes sense for now.

Applied to main and backported down to 3.3.  Thanks!

Best regards, Ilya Maximets.
diff mbox series

Patch

diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
index 0cb379295af1..ec6fcf7b2c6a 100644
--- a/lib/netdev-linux.c
+++ b/lib/netdev-linux.c
@@ -2402,6 +2402,7 @@  static int
 netdev_linux_read_stringset_info(struct netdev_linux *netdev, uint32_t *len)
 {
     union {
+        struct ethtool_cmd ecmd;
         struct ethtool_sset_info hdr;
         struct {
             uint64_t pad[2];