diff options
| author | Dmitry Antipov <dmantipov@yandex.ru> | 2023-12-11 12:05:32 +0300 |
|---|---|---|
| committer | Jakub Kicinski <kuba@kernel.org> | 2023-12-12 13:20:37 -0800 |
| commit | 2a62644800208fcba79a55b297ec0d9aad115221 (patch) | |
| tree | 68813d8935f7def9770eb4cbac3afac7997bdcd7 /drivers/net/ethernet/asix/ax88796c_main.h | |
| parent | Merge branch 'net-dsa-realtek-two-rtl8366rb-fixes' (diff) | |
| download | linux-2a62644800208fcba79a55b297ec0d9aad115221.tar.gz linux-2a62644800208fcba79a55b297ec0d9aad115221.zip | |
net: asix: fix fortify warning
When compiling with gcc version 14.0.0 20231129 (experimental) and
CONFIG_FORTIFY_SOURCE=y, I've noticed the following warning:
...
In function 'fortify_memcpy_chk',
inlined from 'ax88796c_tx_fixup' at drivers/net/ethernet/asix/ax88796c_main.c:287:2:
./include/linux/fortify-string.h:588:25: warning: call to '__read_overflow2_field'
declared with attribute warning: detected read beyond size of field (2nd parameter);
maybe use struct_group()? [-Wattribute-warning]
588 | __read_overflow2_field(q_size_field, size);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
This call to 'memcpy()' is interpreted as an attempt to copy TX_OVERHEAD
(which is 8) bytes from 4-byte 'sop' field of 'struct tx_pkt_info' and
thus overread warning is issued. Since we actually want to copy both
'sop' and 'seg' fields at once, use the convenient 'struct_group()' here.
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Acked-by: Ćukasz Stelmach <l.stelmach@samsung.com>
Link: https://lore.kernel.org/r/20231211090535.9730-1-dmantipov@yandex.ru
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'drivers/net/ethernet/asix/ax88796c_main.h')
| -rw-r--r-- | drivers/net/ethernet/asix/ax88796c_main.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/net/ethernet/asix/ax88796c_main.h b/drivers/net/ethernet/asix/ax88796c_main.h index 4a83c991dcbe..68a09edecab8 100644 --- a/drivers/net/ethernet/asix/ax88796c_main.h +++ b/drivers/net/ethernet/asix/ax88796c_main.h @@ -25,7 +25,7 @@ #define AX88796C_PHY_REGDUMP_LEN 14 #define AX88796C_PHY_ID 0x10 -#define TX_OVERHEAD 8 +#define TX_OVERHEAD sizeof_field(struct tx_pkt_info, tx_overhead) #define TX_EOP_SIZE 4 #define AX_MCAST_FILTER_SIZE 8 @@ -549,8 +549,10 @@ struct tx_eop_header { }; struct tx_pkt_info { - struct tx_sop_header sop; - struct tx_segment_header seg; + struct_group(tx_overhead, + struct tx_sop_header sop; + struct tx_segment_header seg; + ); struct tx_eop_header eop; u16 pkt_len; u16 seq_num; |
