[PATCH 2/6] wifi: ath10k: use flexible arrays for WMI start scan TLVs

Kees Cook keescook at chromium.org
Wed Dec 13 11:11:37 PST 2023

On Wed, Dec 13, 2023 at 09:06:40AM -0800, Jeff Johnson wrote:
> Currently ath10k defines the following struct:
> 	struct wmi_start_scan_tlvs {
> 		u8 tlvs[0];
> 	} __packed;
> Per the guidance in [1] this should be a flexible array. However, a
> direct replace to u8 tlvs[] results in the compilation error:
>        flexible array member in a struct with no named members
> This is because C99 (16) requires that a structure containing
> a flexible array member must have more than one named member.
> So rather than defining a separate struct wmi_start_scan_tlvs which
> contains the flexible tlvs[] array, just define the tlvs[] array where
> struct wmi_start_scan_tlvs is being used.
> No functional changes, compile tested only.
> [1] https://docs.kernel.org/process/deprecated.html#zero-length-and-one-element-arrays
> Signed-off-by: Jeff Johnson <quic_jjohnson at quicinc.com>

Yeah, this too looks like the right approach: keeping the flex array
close instead of externalized into a no-op struct.

Reviewed-by: Kees Cook <keescook at chromium.org>

Kees Cook

More information about the ath10k mailing list