1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00
linux/drivers/net/ethernet/atheros/alx
GONG, Ruiqi 3a198c95c9 alx: fix OOB-read compiler warning
The following message shows up when compiling with W=1:

In function ‘fortify_memcpy_chk’,
    inlined from ‘alx_get_ethtool_stats’ at drivers/net/ethernet/atheros/alx/ethtool.c:297:2:
./include/linux/fortify-string.h:592:4: error: call to ‘__read_overflow2_field’
declared with attribute warning: detected read beyond size of field (2nd parameter);
maybe use struct_group()? [-Werror=attribute-warning]
  592 |    __read_overflow2_field(q_size_field, size);
      |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In order to get alx stats altogether, alx_get_ethtool_stats() reads
beyond hw->stats.rx_ok. Fix this warning by directly copying hw->stats,
and refactor the unnecessarily complicated BUILD_BUG_ON btw.

Signed-off-by: GONG, Ruiqi <gongruiqi1@huawei.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/20230821013218.1614265-1-gongruiqi@huaweicloud.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2023-08-22 12:30:15 +02:00
..
alx.h alx: use fine-grained locking instead of RTNL 2021-05-13 13:09:26 -07:00
ethtool.c alx: fix OOB-read compiler warning 2023-08-22 12:30:15 +02:00
hw.c alx: add msi-x support 2016-09-09 20:51:21 -07:00
hw.h ethernet/atheros: use core min/max MTU checking 2016-10-18 11:34:18 -04:00
main.c alx: Drop redundant pci_enable_pcie_error_reporting() 2023-03-08 23:34:38 -08:00
Makefile treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
reg.h Add Killer E2500 device ID in alx driver. 2016-08-29 00:23:50 -04:00