ath11k: Replace zero-length arrays with flexible-array members
Subsystems (3)
PATCH 1/1 ath11k: Replace zero-length arrays with flexible-array members
There is a regular need in the kernel to provide a way to declare having a dynamically sized set of trailing elements in a structure. Kernel code should always use “flexible array members”[1] for these cases. The older style of one-element or zero-length arrays should no longer be used[2].
[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays
--- drivers/net/wireless/ath/ath11k/ce.h | 2 +- drivers/net/wireless/ath/ath11k/core.h | 2 +- drivers/net/wireless/ath/ath11k/dp.h | 10 +++++----- drivers/net/wireless/ath/ath11k/rx_desc.h | 6 +++--- drivers/net/wireless/ath/ath11k/spectral.c | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-)
drivers/net/wireless/ath/ath11k/ce.h +1 -1
@@ -145,7 +145,7 @@ struct ath11k_ce_ring {u32 hal_ring_id;/* keep last */ -struct sk_buff *skb[0 ]; +struct sk_buff *skb[]; };struct ath11k_ce_pipe {
drivers/net/wireless/ath/ath11k/core.h +1 -1
@@ -806,7 +806,7 @@ struct ath11k_base { } id;/* must be last */ -u8 drv_priv[0 ]__aligned(sizeof(void *)) ; +u8 drv_priv[]__aligned(sizeof(void *)) ; };struct ath11k_fw_stats_pdev {
drivers/net/wireless/ath/ath11k/dp.h +5 -5
@@ -1170,12 +1170,12 @@ struct ath11k_htt_ppdu_stats_msg {u32 ppdu_id;u32 timestamp;u32 rsvd; -u8 data[0 ]; +u8 data[]; } __packed;struct htt_tlv {u32 header; -u8 value[0 ]; +u8 value[]; } __packed;#define HTT_TLV_TAG GENMASK(11, 0)
@@ -1362,7 +1362,7 @@ struct htt_ppdu_stats_usr_cmn_array {* tx_ppdu_stats_info is variable length, with length = * number_of_ppdu_stats * sizeof (struct htt_tx_ppdu_stats_info) */ -struct htt_tx_ppdu_stats_info tx_ppdu_info[0 ]; +struct htt_tx_ppdu_stats_info tx_ppdu_info[]; } __packed;struct htt_ppdu_user_stats {
@@ -1424,7 +1424,7 @@ struct htt_ppdu_stats_info {*/ struct htt_pktlog_msg {u32 hdr; -u8 payload[0 ]; +u8 payload[]; };/**
@@ -1645,7 +1645,7 @@ struct ath11k_htt_extd_stats_msg {u32 info0;u64 cookie;u32 info1; -u8 data[0 ]; +u8 data[]; } __packed;#define HTT_MAC_ADDR_L32_0 GENMASK(7, 0)
drivers/net/wireless/ath/ath11k/rx_desc.h +3 -3
@@ -1445,7 +1445,7 @@ struct hal_rx_desc_ipq8074 {__le32 hdr_status_tag;__le32 phy_ppdu_id;u8 hdr_status[HAL_RX_DESC_HDR_STATUS_LEN ]; -u8 msdu_payload[0 ]; +u8 msdu_payload[]; } __packed;struct hal_rx_desc_qcn9074 {
@@ -1464,7 +1464,7 @@ struct hal_rx_desc_qcn9074 {__le32 hdr_status_tag;__le32 phy_ppdu_id;u8 hdr_status[HAL_RX_DESC_HDR_STATUS_LEN ]; -u8 msdu_payload[0 ]; +u8 msdu_payload[]; } __packed;struct hal_rx_desc_wcn6855 {
@@ -1483,7 +1483,7 @@ struct hal_rx_desc_wcn6855 {__le32 hdr_status_tag;__le32 phy_ppdu_id;u8 hdr_status[HAL_RX_DESC_HDR_STATUS_LEN ]; -u8 msdu_payload[0 ]; +u8 msdu_payload[]; } __packed;struct hal_rx_desc {
drivers/net/wireless/ath/ath11k/spectral.c +1 -1
@@ -107,7 +107,7 @@ struct spectral_search_fft_report {__le32 info1;__le32 info2;__le32 reserve0; -u8 bins[0 ]; +u8 bins[]; } __packed;struct ath11k_spectral_search_report {
Signature · 7 lines
2.27.0 -- ath11k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath11k
Quoted 11 lines · Gustavo A. R. Silva
There is a regular need in the kernel to provide a way to declare having a dynamically sized set of trailing elements in a structure. Kernel code should always use “flexible array members”[1] for these cases. The older style of one-element or zero-length arrays should no longer be used[2].
[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays
Signature · 6 lines
Kees Cook -- ath11k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath11k
Quoted 6 lines · Gustavo A. R. Silva
There is a regular need in the kernel to provide a way to declare having a dynamically sized set of trailing elements in a structure. Kernel code should always use “flexible array members”[1] for these cases. The older style of one-element or zero-length arrays should no longer be used[2].
Quoted 7 lines
[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arraysSigned-off-by Gustavo A. R. Silva <[email protected]>Reviewed-by Kees Cook <[email protected]>Signed-off-by Kalle Valo <[email protected]>
Patch applied to ath-next branch of ath.git, thanks.
e9e591686ccb ath11k: Replace zero-length arrays with flexible-array members
Signature · 9 lines
https://patchwork.kernel.org/project/linux-wireless/patch/20220216194836.GA904035@embeddedor/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches -- ath11k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath11k