WSL2-Linux-Kernel/drivers/net/ethernet/freescale
Vladimir Oltean 289d0822be net: dpaa: avoid on-stack arrays of NR_CPUS elements
[ Upstream commit 555a05d84ca2c587e2d4777006e2c2fb3dfbd91d ]

The dpaa-eth driver is written for PowerPC and Arm SoCs which have 1-24
CPUs. It depends on CONFIG_NR_CPUS having a reasonably small value in
Kconfig. Otherwise, there are 2 functions which allocate on-stack arrays
of NR_CPUS elements, and these can quickly explode in size, leading to
warnings such as:

  drivers/net/ethernet/freescale/dpaa/dpaa_eth.c:3280:12: warning:
  stack frame size (16664) exceeds limit (2048) in 'dpaa_eth_probe' [-Wframe-larger-than]

The problem is twofold:
- Reducing the array size to the boot-time num_possible_cpus() (rather
  than the compile-time NR_CPUS) creates a variable-length array,
  which should be avoided in the Linux kernel.
- Using NR_CPUS as an array size makes the driver blow up in stack
  consumption with generic, as opposed to hand-crafted, .config files.

A simple solution is to use dynamic allocation for num_possible_cpus()
elements (aka a small number determined at runtime).

Link: https://lore.kernel.org/all/202406261920.l5pzM1rj-lkp@intel.com/
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Breno Leitao <leitao@debian.org>
Acked-by: Madalin Bucur <madalin.bucur@oss.nxp.com>
Link: https://patch.msgid.link/20240713225336.1746343-2-vladimir.oltean@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-09-12 11:07:49 +02:00
..
dpaa net: dpaa: avoid on-stack arrays of NR_CPUS elements 2024-09-12 11:07:49 +02:00
dpaa2 dpaa2-switch: Fix error checking in dpaa2_switch_seed_bp() 2024-09-04 13:23:33 +02:00
enetc net: enetc: use EXPORT_SYMBOL_GPL for enetc_phc_index 2023-09-06 21:28:37 +01:00
fman ethernet: constify references to netdev->dev_addr in drivers 2024-01-05 15:13:37 +01:00
fs_enet ethernet: use of_get_ethdev_address() 2023-07-27 08:47:00 +02:00
Kconfig ethernet: fix PTP_1588_CLOCK dependencies 2021-08-13 17:49:05 -07:00
Makefile net: enetc: fix link error again 2021-04-22 13:23:07 -07:00
fec.h net: fec: only clear interrupt of handling queue in fec_enet_rx_queue() 2021-12-14 10:57:19 +01:00
fec_main.c net: fec: Fix FEC_ECR_EN1588 being cleared on link-down 2024-08-19 05:44:57 +02:00
fec_mpc52xx.c ethernet: use of_get_ethdev_address() 2023-07-27 08:47:00 +02:00
fec_mpc52xx.h
fec_mpc52xx_phy.c
fec_ptp.c net: fec: Stop PPS on driver remove 2024-08-19 05:45:36 +02:00
fsl_pq_mdio.c
gianfar.c ethernet: use of_get_ethdev_address() 2023-07-27 08:47:00 +02:00
gianfar.h net: gianfar: Implement rx_missed_errors counter 2021-06-17 11:39:48 -07:00
gianfar_ethtool.c gianfar: ethtool: Fix refcount leak in gfar_get_ts_info 2022-03-16 14:23:39 +01:00
ucc_geth.c ethernet: use of_get_ethdev_address() 2023-07-27 08:47:00 +02:00
ucc_geth.h
ucc_geth_ethtool.c
xgmac_mdio.c net/fsl: xgmac_mdio: Fix incorrect iounmap when removing module 2022-01-27 11:05:28 +01:00