linux-stable/drivers/fpga
Marco Pagani 2279c09c36 fpga: region: add owner module and take its refcount
[ Upstream commit b7c0e1ecee ]

The current implementation of the fpga region assumes that the low-level
module registers a driver for the parent device and uses its owner pointer
to take the module's refcount. This approach is problematic since it can
lead to a null pointer dereference while attempting to get the region
during programming if the parent device does not have a driver.

To address this problem, add a module owner pointer to the fpga_region
struct and use it to take the module's refcount. Modify the functions for
registering a region to take an additional owner module parameter and
rename them to avoid conflicts. Use the old function names for helper
macros that automatically set the module that registers the region as the
owner. This ensures compatibility with existing low-level control modules
and reduces the chances of registering a region without setting the owner.

Also, update the documentation to keep it consistent with the new interface
for registering an fpga region.

Fixes: 0fa20cdfcc ("fpga: fpga-region: device tree control for FPGA")
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Suggested-by: Xu Yilun <yilun.xu@intel.com>
Reviewed-by: Russ Weight <russ.weight@linux.dev>
Signed-off-by: Marco Pagani <marpagan@redhat.com>
Acked-by: Xu Yilun <yilun.xu@intel.com>
Link: https://lore.kernel.org/r/20240419083601.77403-1-marpagan@redhat.com
Signed-off-by: Xu Yilun <yilun.xu@linux.intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-06-12 11:39:13 +02:00
..
tests fpga: Fix memory leak for fpga_region_test_class_find() 2023-10-24 19:32:39 +02:00
Kconfig fpga: add configuration for the FPGA KUnit test suites. 2023-07-23 14:04:50 +08:00
Makefile fpga: add configuration for the FPGA KUnit test suites. 2023-07-23 14:04:50 +08:00
altera-cvp.c fpga: mgr: Use standard dev_release for class driver 2021-11-28 13:59:13 -08:00
altera-fpga2sdram.c fpga: altera-fpga2sdram: Convert to platform remove callback returning void 2023-12-21 22:30:42 +08:00
altera-freeze-bridge.c fpga: altera-freeze-bridge: Convert to platform remove callback returning void 2023-12-21 22:31:40 +08:00
altera-hps2fpga.c fpga: altera-hps2fpga: Convert to platform remove callback returning void 2023-12-21 22:31:53 +08:00
altera-pr-ip-core-plat.c fpga: Explicitly include correct DT includes 2023-07-17 09:23:04 +08:00
altera-pr-ip-core.c fpga: altera-pr-ip: fix unsigned comparison with less than zero 2022-06-10 15:48:23 +08:00
altera-ps-spi.c fpga: altera-ps-spi: Use spi_get_device_match_data() 2023-10-16 10:19:51 +08:00
dfl-afu-dma-region.c
dfl-afu-error.c fpga: dfl: afu: harden port enable logic 2021-03-24 11:15:04 -07:00
dfl-afu-main.c fpga: dfl-afu-main: Convert to platform remove callback returning void 2023-12-21 22:32:06 +08:00
dfl-afu-region.c fpga: dfl: more kernel-doc corrections 2023-01-28 23:33:43 +08:00
dfl-afu.h fpga: dfl: more kernel-doc corrections 2023-01-28 23:33:43 +08:00
dfl-fme-br.c fpga: dfl-fme-br: Convert to platform remove callback returning void 2023-12-21 22:32:19 +08:00
dfl-fme-error.c
dfl-fme-main.c fpga: dfl-fme-main: Convert to platform remove callback returning void 2023-12-21 22:32:30 +08:00
dfl-fme-mgr.c fpga: dfl-fme-mgr: Convert to devm_platform_ioremap_resource() 2023-07-10 16:41:44 +08:00
dfl-fme-perf.c fpga: dfl: more kernel-doc corrections 2023-01-28 23:33:43 +08:00
dfl-fme-pr.c fpga: dfl: kernel-doc corrections 2023-01-28 23:33:05 +08:00
dfl-fme-pr.h fpga: dfl: more kernel-doc corrections 2023-01-28 23:33:43 +08:00
dfl-fme-region.c fpga: dfl-fme-region: Convert to platform remove callback returning void 2023-12-21 22:32:40 +08:00
dfl-fme.h
dfl-n3000-nios.c fpga: fix spelling mistakes 2021-07-21 19:54:21 -07:00
dfl-pci.c fpga: dfl-pci: add PCI subdevice ID for Intel D5005 card 2024-04-26 12:14:28 +08:00
dfl.c fpga: dfl: make dfl_bus_type const 2024-02-18 18:07:05 +08:00
dfl.h Char/Misc and other driver subsystem changes for 6.3-rc1 2023-02-24 12:47:33 -08:00
fpga-bridge.c fpga: bridge: add owner module and take its refcount 2024-06-12 11:39:06 +02:00
fpga-mgr.c fpga: manager: add owner module and take its refcount 2024-06-12 11:39:06 +02:00
fpga-region.c fpga: region: add owner module and take its refcount 2024-06-12 11:39:13 +02:00
ice40-spi.c fpga: ice40-spi: Follow renaming of SPI "master" to "controller" 2024-02-08 11:54:35 +00:00
intel-m10-bmc-sec-update.c fpga: intel-m10-bmc-sec-update: Convert to platform remove callback returning void 2023-12-21 22:32:54 +08:00
lattice-sysconfig-spi.c fpga: lattice-sysconfig-spi: Add explicit include for of.h 2023-04-06 20:36:27 +02:00
lattice-sysconfig.c fpga: lattice-sysconfig-spi: add Lattice sysCONFIG FPGA manager 2022-10-25 14:44:03 +08:00
lattice-sysconfig.h fpga: lattice-sysconfig-spi: add Lattice sysCONFIG FPGA manager 2022-10-25 14:44:03 +08:00
machxo2-spi.c fpga: mgr: Use standard dev_release for class driver 2021-11-28 13:59:13 -08:00
microchip-spi.c fpga: Explicitly include correct DT includes 2023-07-17 09:23:04 +08:00
of-fpga-region.c fpga: of-fpga-region: Convert to platform remove callback returning void 2023-12-21 22:33:04 +08:00
socfpga-a10.c fpga: socfpga-a10: Convert to platform remove callback returning void 2023-12-21 22:33:15 +08:00
socfpga.c fpga: fpga-mgr: socfpga: Convert to devm_platform_ioremap_resource() 2023-07-10 16:48:04 +08:00
stratix10-soc.c fpga: stratix10-soc: Convert to platform remove callback returning void 2023-12-21 22:33:25 +08:00
ts73xx-fpga.c fpga: fpga-mgr: ts73xx: Convert to devm_platform_ioremap_resource() 2023-07-10 16:52:58 +08:00
versal-fpga.c fpga: versal: Add support for 44-bit DMA operations 2023-10-16 10:32:00 +08:00
xilinx-pr-decoupler.c fpga: xilinx-pr-decoupler: Convert to platform remove callback returning void 2023-12-21 22:33:35 +08:00
xilinx-spi.c fpga: mgr: Use standard dev_release for class driver 2021-11-28 13:59:13 -08:00
zynq-fpga.c fpga: zynq-fpga: Convert to platform remove callback returning void 2023-12-21 22:33:46 +08:00
zynqmp-fpga.c fpga: zynqmp-fpga: Adds status interface 2023-03-09 17:33:19 +01:00