alistair23-linux/drivers/net
Gustavo A. R. Silva e94c0df984 ice: Replace one-element array with flexible-array member
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].

Refactor the code according to the use of a flexible-array member in
struct ice_res_tracker, instead of a one-element array and use the
struct_size() helper to calculate the size for the allocations.

Also, notice that the code below suggests that, currently, two too many
bytes are being allocated with devm_kzalloc(), as the total number of
entries (pf->irq_tracker->num_entries) for pf->irq_tracker->list[] is
_vectors_ and sizeof(*pf->irq_tracker) also includes the size of the
one-element array _list_ in struct ice_res_tracker.

drivers/net/ethernet/intel/ice/ice_main.c:3511:
3511         /* populate SW interrupts pool with number of OS granted IRQs. */
3512         pf->num_avail_sw_msix = (u16)vectors;
3513         pf->irq_tracker->num_entries = (u16)vectors;
3514         pf->irq_tracker->end = pf->irq_tracker->num_entries;

With this change, the right amount of dynamic memory is now allocated
because, contrary to one-element arrays which occupy at least as much
space as a single object of the type, flexible-array members don't
occupy such space in the containing structure.

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.9-rc1/process/deprecated.html#zero-length-and-one-element-arrays

Built-tested-by: kernel test robot <lkp@intel.com>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Tested-by: Tony Brelinski <tonyx.brelinski@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
2021-02-05 11:44:32 -08:00
..
appletalk
arcnet arcnet: use new tasklet API 2021-02-02 15:51:17 -08:00
bonding
caif caif_virtio: use new tasklet API 2021-02-02 15:51:17 -08:00
can can: mcp251xfd: mcp251xfd_probe(): use dev_err_probe() to simplify error handling 2021-01-29 09:31:58 +01:00
dsa net: dsa: xrs700x: Correctly address device over I2C 2021-02-04 19:09:47 -08:00
ethernet ice: Replace one-element array with flexible-array member 2021-02-05 11:44:32 -08:00
fddi
fjes
hamradio
hippi
hyperv hv_netvsc: Load and store the proper (NBL_HASH_INFO) per-packet info 2021-02-04 20:37:04 -08:00
ieee802154
ipa net: ipa: expand last transaction check 2021-02-02 17:42:36 -08:00
ipvlan ipvlan: remove h from printk format specifier 2021-01-28 17:47:33 -08:00
mdio
netdevsim net: Do not call fib6_info_hw_flags_set() when IPv6 is disabled 2021-02-02 17:45:59 -08:00
pcs
phy net: mdiobus: Prevent spike on MDIO bus reset signal 2021-02-03 17:28:05 -08:00
plip
ppp ppp: use new tasklet API 2021-02-02 15:51:18 -08:00
slip
team team: protect features update by RCU to avoid deadlock 2021-01-26 17:08:59 -08:00
usb r8152: adjust the flow of power cut for RTL8153B 2021-02-04 20:36:51 -08:00
vmxnet3 vmxnet3: Remove buf_info from device accessible structures 2021-01-29 21:07:03 -08:00
wan
wireguard
wireless Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2021-01-28 17:09:31 -08:00
xen-netback
bareudp.c udp: call udp_encap_enable for v6 sockets when enabling encap 2021-02-04 18:37:14 -08:00
dummy.c
eql.c
geneve.c
gtp.c gtp: update rx_length_errors for abnormally short packets 2021-02-04 09:29:58 -08:00
ifb.c ifb: use new tasklet API 2021-02-02 15:51:18 -08:00
Kconfig bonding: add TLS dependency 2021-01-26 17:45:55 -08:00
LICENSE.SRC
loopback.c net-loopback: set lo dev initial state to UP 2021-02-04 18:37:08 -08:00
macsec.c
macvlan.c
macvtap.c
Makefile
mdio.c
mhi_net.c net: mhi: Get rid of local rx queue count 2021-01-29 19:42:06 -08:00
mii.c
net_failover.c
netconsole.c
nlmon.c
ntb_netdev.c
rionet.c
sb1000.c
Space.c
sungem_phy.c
tap.c
thunderbolt.c
tun.c
veth.c
virtio_net.c
vrf.c
vsockmon.c
vxlan.c
xen-netfront.c drivers: net: xen-netfront: Simplify the calculation of variables 2021-02-04 10:55:24 -08:00