Skip to content

Commit 2af7e56

Browse files
Saeed Mahameedkuba-moo
Saeed Mahameed
authored andcommitted
net/mlx5e: Fix build warning, detected write beyond size of field
When merged with Linus tree, the cited patch below will cause the following build warning: In function 'fortify_memset_chk', inlined from 'mlx5e_xmit_xdp_frame' at drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c:438:3: include/linux/fortify-string.h:242:25: error: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning] 242 | __write_overflow_field(p_size_field, size); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Fix that by grouping the fields to memeset in struct_group() to avoid the false alarm. Fixes: 9ded70f ("net/mlx5e: Don't prefill WQEs in XDP SQ in the multi buffer mode") Reported-by: Stephen Rothwell <[email protected]> Suggested-by: Stephen Rothwell <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent b20bdd9 commit 2af7e56

File tree

2 files changed

+6
-2
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core/en
  • include/linux/mlx5

2 files changed

+6
-2
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,8 +435,7 @@ mlx5e_xmit_xdp_frame(struct mlx5e_xdpsq *sq, struct mlx5e_xmit_data *xdptxd,
435435
u8 num_pkts = 1 + num_frags;
436436
int i;
437437

438-
memset(&cseg->signature, 0, sizeof(*cseg) -
439-
sizeof(cseg->opmod_idx_opcode) - sizeof(cseg->qpn_ds));
438+
memset(&cseg->trailer, 0, sizeof(cseg->trailer));
440439
memset(eseg, 0, sizeof(*eseg) - sizeof(eseg->trailer));
441440

442441
eseg->inline_hdr.sz = cpu_to_be16(inline_hdr_sz);

include/linux/mlx5/qp.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@ struct mlx5_wqe_fmr_seg {
202202
struct mlx5_wqe_ctrl_seg {
203203
__be32 opmod_idx_opcode;
204204
__be32 qpn_ds;
205+
206+
struct_group(trailer,
207+
205208
u8 signature;
206209
u8 rsvd[2];
207210
u8 fm_ce_se;
@@ -211,6 +214,8 @@ struct mlx5_wqe_ctrl_seg {
211214
__be32 umr_mkey;
212215
__be32 tis_tir_num;
213216
};
217+
218+
); /* end of trailer group */
214219
};
215220

216221
#define MLX5_WQE_CTRL_DS_MASK 0x3f

0 commit comments

Comments
 (0)