]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
IB/hfi1: Replace 1-element array with singleton
authorKees Cook <keescook@chromium.org>
Fri, 18 Nov 2022 21:58:51 +0000 (13:58 -0800)
committerJason Gunthorpe <jgg@nvidia.com>
Fri, 18 Nov 2022 23:54:11 +0000 (19:54 -0400)
commit8f649b57856b855f8a28724321e7ae72e31d513a
tree12cd9b7421a64ec0a8a1e50f9768b645c5ca229b
parent34a046f08b62fb855ac590c1f4dfb1934f1fdb64
IB/hfi1: Replace 1-element array with singleton

Zero-length arrays are deprecated[1] and are being replaced with flexible
array members in support of the ongoing efforts to tighten the
FORTIFY_SOURCE routines on memcpy(), correctly instrument array indexing
with UBSAN_BOUNDS, and to globally enable -fstrict-flex-arrays=3.

Replace zero-length array with flexible-array member "lvs" in struct
opa_port_data_counters_msg and struct opa_port_error_counters64_msg.

Additionally, the "port" member of several structs is defined as a
single-element, but is only ever accessed at index 0. Replace it with a
singleton so that flexible array usage is sane.

This results in no differences in binary output.

[1] https://github.com/KSPP/linux/issues/78

Link: https://lore.kernel.org/r/20221118215847.never.416-kees@kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/hw/hfi1/mad.c