On Wed, Dec 13, 2023 at 09:06:39AM -0800, Jeff Johnson wrote:
> Currently struct wmi_host_mem_chunks defines:
>       struct host_memory_chunk items[1];
> 
> Per the guidance in [1] this should be a flexible array. However there
> is a documented requirement:
>       some fw revisions require at least 1 chunk regardless of count
> 
> To satisfy this requirement, follow the guidance from [2] and wrap the
> array in a union which contains both the flexible array and a single
> instance of the underlying struct. Since the footprint of the struct
> is unchanged, no additional driver changes are required.
> 
> No functional changes, compile tested only.
> 
> [1] 
> https://docs.kernel.org/process/deprecated.html#zero-length-and-one-element-arrays
> [2] https://lore.kernel.org/linux-wireless/202308301529.AC90A9EF98@keescook/
> 
> Signed-off-by: Jeff Johnson <[email protected]>

This looks like the right approach here.

Reviewed-by: Kees Cook <[email protected]>

-- 
Kees Cook

Reply via email to