6f2f49ae4c
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]. Use flexible-array members in struct hfi_msg_sys_property_info_pkt and hfi_msg_session_property_info_pkt instead of one-element arrays, and refactor the code accordingly. Also, this helps with the ongoing efforts to enable -Warray-bounds by fixing the following warnings: CC [M] drivers/media/platform/qcom/venus/hfi_msgs.o drivers/media/platform/qcom/venus/hfi_msgs.c: In function ‘hfi_sys_property_info’: drivers/media/platform/qcom/venus/hfi_msgs.c:246:35: warning: array subscript 1 is above array bounds of ‘u32[1]’ {aka ‘unsigned int[1]’} [-Warray-bounds] 246 | if (req_bytes < 128 || !pkt->data[1] || pkt->num_properties > 1) | ~~~~~~~~~^~~ drivers/media/platform/qcom/venus/hfi_msgs.c: In function ‘hfi_session_prop_info’: drivers/media/platform/qcom/venus/hfi_msgs.c:342:62: warning: array subscript 1 is above array bounds of ‘u32[1]’ {aka ‘unsigned int[1]’} [-Warray-bounds] 342 | if (!req_bytes || req_bytes % sizeof(*buf_req) || !pkt->data[1]) | ~~~~~~~~~^~~ [1] https://en.wikipedia.org/wiki/Flexible_array_member [2] https://www.kernel.org/doc/html/v5.9/process/deprecated.html#zero-length-and-one-element-arrays Link: https://github.com/KSPP/linux/issues/79 Link: https://github.com/KSPP/linux/issues/109 Co-developed-by: Kees Cook <keescook@chromium.org> Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> |
||
---|---|---|
.. | ||
core.c | ||
core.h | ||
dbgfs.c | ||
dbgfs.h | ||
firmware.c | ||
firmware.h | ||
helpers.c | ||
helpers.h | ||
hfi_cmds.c | ||
hfi_cmds.h | ||
hfi_helper.h | ||
hfi_msgs.c | ||
hfi_msgs.h | ||
hfi_parser.c | ||
hfi_parser.h | ||
hfi_plat_bufs_v6.c | ||
hfi_plat_bufs.h | ||
hfi_platform_v4.c | ||
hfi_platform_v6.c | ||
hfi_platform.c | ||
hfi_platform.h | ||
hfi_venus_io.h | ||
hfi_venus.c | ||
hfi_venus.h | ||
hfi.c | ||
hfi.h | ||
Makefile | ||
pm_helpers.c | ||
pm_helpers.h | ||
vdec_ctrls.c | ||
vdec.c | ||
vdec.h | ||
venc_ctrls.c | ||
venc.c | ||
venc.h |