linux/drivers/media/platform/qcom/venus
Gustavo A. R. Silva 6f2f49ae4c media: venus: hfi_msgs.h: Replace one-element 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].

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>
2021-06-17 09:42:30 +02:00
..
core.c media: venus: Rework error fail recover logic 2021-05-10 11:36:33 +02:00
core.h media: venus: Enable low power setting for encoder 2021-06-02 12:28:17 +02:00
dbgfs.c media: venus: place extern venus_fw_debug on a header file 2020-09-03 11:09:54 +02:00
dbgfs.h media: venus: Add debugfs interface to set firmware log level 2020-09-01 14:13:30 +02:00
firmware.c media: venus: firmware: Do not toggle WRAPPER_A9SS_SW_RESET on 6xx 2021-04-06 15:57:27 +02:00
firmware.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 284 2019-06-05 17:36:37 +02:00
helpers.c media: venus: helpers: Delete an unneeded bool conversion 2021-06-02 12:28:59 +02:00
helpers.h media: venus: helper: Decide work mode 2021-04-06 16:00:54 +02:00
hfi_cmds.c media: venus: hfi_cmds: Fix packet size calculation 2021-06-17 09:40:31 +02:00
hfi_cmds.h media: venus: hfi_cmds.h: Replace one-element array with flexible-array member 2021-06-02 12:25:44 +02:00
hfi_helper.h media: venus: Enable low power setting for encoder 2021-06-02 12:28:17 +02:00
hfi_msgs.c media: venus: hfi_msgs.h: Replace one-element arrays with flexible-array members 2021-06-17 09:42:30 +02:00
hfi_msgs.h media: venus: hfi_msgs.h: Replace one-element arrays with flexible-array members 2021-06-17 09:42:30 +02:00
hfi_parser.c media: venus: hfi_parser: Check for instance after hfi platform get 2021-04-06 14:50:32 +02:00
hfi_parser.h media: venus: helpers: Wire up hfi platform buffer requirements 2021-01-13 09:20:55 +01:00
hfi_plat_bufs_v6.c media: venus: Fix internal buffer size calculations for v6. 2021-04-15 13:13:46 +02:00
hfi_plat_bufs.h media: venus: Add platform buffers for v6 2021-01-13 09:19:23 +01:00
hfi_platform_v4.c media: venus: Enable low power setting for encoder 2021-06-02 12:28:17 +02:00
hfi_platform_v6.c media: venus: Enable low power setting for encoder 2021-06-02 12:28:17 +02:00
hfi_platform.c media: venus: Enable low power setting for encoder 2021-06-02 12:28:17 +02:00
hfi_platform.h media: venus: Enable low power setting for encoder 2021-06-02 12:28:17 +02:00
hfi_venus_io.h media: venus: hfi: Define additional 6xx registers 2021-04-06 15:26:31 +02:00
hfi_venus.c media: venus: don't de-reference NULL pointers at IRQ time 2021-04-08 10:04:20 +02:00
hfi_venus.h media: venus: Add new interface queues reinit 2020-09-01 14:13:29 +02:00
hfi.c media: venus: hfi: Correct session init return error 2021-01-13 09:08:18 +01:00
hfi.h media: venus: Add new interface queues reinit 2020-09-01 14:13:29 +02:00
Makefile media: venus: Add platform buffers for v6 2021-01-13 09:19:23 +01:00
pm_helpers.c media: venus: Enable low power setting for encoder 2021-06-02 12:28:17 +02:00
pm_helpers.h media: venus: core, venc, vdec: Fix probe dependency error 2021-03-22 09:37:02 +01:00
vdec_ctrls.c media: venus: vdec: Add support for conceal control 2021-04-06 14:54:46 +02:00
vdec.c media: venus: vdec: use pm_runtime_resume_and_get() 2021-05-19 09:51:43 +02:00
vdec.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 284 2019-06-05 17:36:37 +02:00
venc_ctrls.c media: venus: venc: Add support for CLL and Mastering display controls 2021-04-06 14:57:15 +02:00
venc.c media: venus: venc: use pm_runtime_resume_and_get() 2021-05-19 09:51:43 +02:00
venc.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 284 2019-06-05 17:36:37 +02:00