]> Git Repo - J-linux.git/commit
fpga: region: add owner module and take its refcount
authorMarco Pagani <[email protected]>
Fri, 19 Apr 2024 08:35:59 +0000 (10:35 +0200)
committerXu Yilun <[email protected]>
Tue, 23 Apr 2024 07:37:20 +0000 (15:37 +0800)
commitb7c0e1ecee403a43abc89eb3e75672b01ff2ece9
tree516571ae2bed48a9ddf2940c55a2358aea817870
parentdbca8048b33c8e612d3bb7d314cfe002d9478daa
fpga: region: add owner module and take its refcount

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: 0fa20cdfcc1f ("fpga: fpga-region: device tree control for FPGA")
Suggested-by: Greg Kroah-Hartman <[email protected]>
Suggested-by: Xu Yilun <[email protected]>
Reviewed-by: Russ Weight <[email protected]>
Signed-off-by: Marco Pagani <[email protected]>
Acked-by: Xu Yilun <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Xu Yilun <[email protected]>
Documentation/driver-api/fpga/fpga-region.rst
drivers/fpga/fpga-region.c
include/linux/fpga/fpga-region.h
This page took 0.050457 seconds and 4 git commands to generate.