linux/drivers/soc
Richard Genoud d288fbe652 soc: fsl: qbman: fix race condition in qman_destroy_fq
[ Upstream commit 014077044e ]

When QMAN_FQ_FLAG_DYNAMIC_FQID is set, there's a race condition between
fq_table[fq->idx] state and freeing/allocating from the pool and
WARN_ON(fq_table[fq->idx]) in qman_create_fq() gets triggered.

Indeed, we can have:
         Thread A                             Thread B
    qman_destroy_fq()                    qman_create_fq()
      qman_release_fqid()
        qman_shutdown_fq()
        gen_pool_free()
           -- At this point, the fqid is available again --
                                           qman_alloc_fqid()
           -- so, we can get the just-freed fqid in thread B --
                                           fq->fqid = fqid;
                                           fq->idx = fqid * 2;
                                           WARN_ON(fq_table[fq->idx]);
                                           fq_table[fq->idx] = fq;
     fq_table[fq->idx] = NULL;

And adding some logs between qman_release_fqid() and
fq_table[fq->idx] = NULL makes the WARN_ON() trigger a lot more.

To prevent that, ensure that fq_table[fq->idx] is set to NULL before
gen_pool_free() is called by using smp_wmb().

Fixes: c535e923bb ("soc/fsl: Introduce DPAA 1.x QMan device driver")
Signed-off-by: Richard Genoud <richard.genoud@bootlin.com>
Tested-by: CHAMPSEIX Thomas <thomas.champseix@alstomgroup.com>
Link: https://lore.kernel.org/r/20251223072549.397625-1-richard.genoud@bootlin.com
Signed-off-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2026-04-18 10:33:19 +02:00
..
actions soc: actions: include header to fix missing prototype 2020-09-22 12:45:16 +05:30
amlogic soc: amlogic: canvas: fix device leak on lookup 2026-01-19 13:09:54 +01:00
aspeed soc: aspeed: socinfo: Add AST27xx silicon IDs 2025-12-07 06:09:16 +09:00
atmel ARM: at91: fix soc detection for SAM9X60 SiPs 2022-07-12 16:35:15 +02:00
bcm pmdomain: bcm: bcm2835-power: Increase ASB control timeout 2026-04-18 10:33:19 +02:00
canaan drivers: bus: Delete CONFIG_SIMPLE_PM_BUS 2021-10-05 17:47:22 +02:00
dove treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
fsl soc: fsl: qbman: fix race condition in qman_destroy_fq 2026-04-18 10:33:19 +02:00
gemini soc: Add SoC driver for Gemini 2018-01-04 17:01:53 +01:00
imx pmdomain: imx: Fix reference count leak in imx_gpc_remove 2025-12-07 06:09:32 +09:00
ixp4xx soc: ixp4xx/npe: Fix unused match warning 2022-07-21 21:24:40 +02:00
lantiq soc: lantiq: convert to devm_platform_ioremap_resource 2020-01-10 11:44:52 -08:00
litex drivers/soc/litex: remove 8-bit subregister option 2021-06-11 04:35:40 +09:00
mediatek soc: mediatek: mtk-devapc: Fix leaking IO map on driver remove 2025-03-13 12:50:50 +01:00
qcom soc: qcom: cmd-db: Use devm_memremap() to fix memory leak in cmd_db_dev_probe 2026-03-04 07:19:29 -05:00
renesas pmdomain: renesas: r8a77980-sysc: CR7 must be always on 2024-03-01 13:21:48 +01:00
rockchip soc: rockchip: Fix refcount leak in rockchip_grf_init 2022-06-14 18:36:07 +02:00
samsung pmdomain: samsung: plug potential memleak during probe 2025-12-07 06:09:32 +09:00
sifive soc: sifive: l2_cache: fix missing of_node_put() in sifive_l2_init() 2023-04-26 13:51:56 +02:00
sunxi soc: sunxi: sram: Fix debugfs info for A64 SRAM C 2022-10-05 10:39:41 +02:00
tegra soc/tegra: pmc: Ensure power-domains are in a known state 2025-08-28 16:24:29 +02:00
ti soc: ti: pruss: Fix double free in pruss_clk_mux_setup() 2026-03-04 07:20:29 -05:00
ux500 ARM: ux500: do not directly dereference __iomem 2023-01-12 11:58:50 +01:00
versatile soc: versatile: realview: fix soc_dev leak during device remove 2024-10-17 15:11:16 +02:00
xilinx drivers: soc: xilinx: check return status of get_api_version() 2024-08-19 05:45:29 +02:00
Kconfig RISC-V Patches for the 5.12 Merge Window 2021-02-26 10:28:35 -08:00
Makefile ARM: ixp4xx: fix compile-testing soc drivers 2021-08-02 14:31:15 +02:00