linux/drivers/media/platform
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
..
allegro-dvt media: allegro-dvt: avoid EN DASH char 2021-06-04 08:10:07 +02:00
am437x media: am437x: fix pm_runtime_get_sync() usage count 2021-05-10 11:36:33 +02:00
atmel media: atmel: atmel-isc: add microchip-xisc driver 2021-06-08 15:46:31 +02:00
cadence media: v4l: cadence: Handle errors of clk_prepare_enable() 2021-06-02 14:04:35 +02:00
coda media: coda: use pm_runtime_resume_and_get() 2021-05-19 09:51:42 +02:00
davinci media: davinci: fix two kernel-doc comments 2021-05-20 16:05:45 +02:00
exynos4-is media: exynos4-is: Fix a use after free in isp_video_release 2021-06-02 13:17:24 +02:00
exynos-gsc media: exynos-gsc: fix pm_runtime_get_sync() usage count 2021-05-10 11:36:34 +02:00
imx-jpeg media: imx-jpeg: Fix double free in mxc_jpeg_remove 2021-04-09 12:54:49 +02:00
marvell-ccic media: marvel-ccic: fix some issues when getting pm_runtime 2021-05-10 11:36:33 +02:00
meson/ge2d media: meson-ge2d: fix rotation parameters 2021-04-15 13:19:28 +02:00
mtk-jpeg media: mtk-jpeg: use pm_runtime_resume_and_get() 2021-05-19 09:51:42 +02:00
mtk-mdp media: mdk-mdp: fix pm_runtime_get_sync() usage count 2021-05-10 11:36:33 +02:00
mtk-vcodec media: mtk-vcodec: fix PM runtime get logic 2021-05-10 11:36:34 +02:00
mtk-vpu media: mtk-vpu: Use devm_platform_ioremap_resource_byname 2021-06-02 13:29:03 +02:00
omap media: videobuf2: Move frame_vector into media subsystem 2021-01-12 14:15:31 +01:00
omap3isp media: omap3isp: Acquire graph mutex for graph traversal 2021-04-06 14:34:20 +02:00
qcom media: venus: hfi_msgs.h: Replace one-element arrays with flexible-array members 2021-06-17 09:42:30 +02:00
rcar-vin media: rcar-csi2: Enable support for r8a77961 2021-06-02 13:27:33 +02:00
rockchip media: rkisp1: use pm_runtime_resume_and_get() 2021-05-20 16:02:43 +02:00
s3c-camif media: s3c-camif: use pm_runtime_resume_and_get() 2021-05-20 16:02:43 +02:00
s5p-g2d media: s5p-g2d: Fix a memory leak in an error handling path in 'g2d_probe()' 2020-07-19 08:14:00 +02:00
s5p-jpeg media: s5p-jpeg: fix pm_runtime_get_sync() usage count 2021-05-10 11:36:34 +02:00
s5p-mfc media: s5p-mfc: use pm_runtime_resume_and_get() 2021-05-20 16:02:43 +02:00
sti media: st-hva: Fix potential NULL pointer dereferences 2021-06-02 14:05:00 +02:00
stm32 media: stm32: use pm_runtime_resume_and_get() 2021-05-20 16:02:43 +02:00
sunxi media: sun6i-csi: add a missing return code 2021-06-17 09:25:48 +02:00
ti-vpe media: ti-vpe: use pm_runtime_resume_and_get() 2021-05-20 16:02:44 +02:00
vsp1 media: vsp1: use pm_runtime_resume_and_get() 2021-05-20 16:02:44 +02:00
xilinx media: xilinx: simplify get fourcc logic 2021-06-17 09:29:41 +02:00
aspeed-video.c media: aspeed: fix clock handling logic 2021-03-11 11:59:45 +01:00
fsl-viu.c media: use getter/setter functions 2021-03-11 11:59:42 +01:00
imx-pxp.c media: imx-pxp: remove redundant dev_err call in pxp_probe() 2021-04-06 16:09:00 +02:00
imx-pxp.h
Kconfig media: venus : hfi: add venus image info into smem 2021-04-15 13:14:09 +02:00
m2m-deinterlace.c media: media/platform: rename VFL_TYPE_GRABBER to _VIDEO 2020-02-24 16:54:14 +01:00
Makefile media: atmel: atmel-isc: add microchip-xisc driver 2021-06-08 15:46:31 +02:00
mx2_emmaprp.c media: mx2_emmaprp: Fix memleak in emmaprp_probe 2020-09-26 10:15:39 +02:00
pxa_camera.c media: use getter/setter functions 2021-03-11 11:59:42 +01:00
rcar_drif.c Revert "media: rcar_drif: fix a memory disclosure" 2021-05-13 17:29:55 +02:00
rcar_fdp1.c media: rcar_fdp1: fix pm_runtime_get_sync() usage count 2021-05-10 11:36:33 +02:00
rcar_jpu.c media: drivers/media/platform/Rcar_jpu.c : fix typo issues 2021-06-02 14:06:51 +02:00
rcar-fcp.c media: rcar-fcp: use pm_runtime_resume_and_get() 2021-05-20 16:02:36 +02:00
renesas-ceu.c media: renesas-ceu: Properly check for PM errors 2021-05-10 11:36:33 +02:00
sh_vou.c media: sh_vou: fix pm_runtime_get_sync() usage count 2021-05-10 11:36:34 +02:00
via-camera.c Power management updates for 5.7-rc1 2020-03-30 15:05:01 -07:00
via-camera.h
video-mux.c media: v4l2-async: Improve v4l2_async_notifier_add_*_subdev() API 2021-02-06 09:18:53 +01:00