]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
fpga: region: fix use-after-free in child_regions_with_firmware()
authorWentao Liang <vulab@iscas.ac.cn>
Wed, 8 Apr 2026 15:45:34 +0000 (15:45 +0000)
committerXu Yilun <yilun.xu@linux.intel.com>
Mon, 4 May 2026 11:27:05 +0000 (19:27 +0800)
Move of_node_put(child_region) after the error print to avoid accessing
freed memory when pr_err() references child_region.

Fixes: 0fa20cdfcc1f ("fpga: fpga-region: device tree control for FPGA")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
[ Yilun: Fix the Fixes tag ]
Reviewed-by: Xu Yilun <yilun.xu@intel.com>
Link: https://lore.kernel.org/r/20260408154534.404327-1-vulab@iscas.ac.cn
Signed-off-by: Xu Yilun <yilun.xu@linux.intel.com>
drivers/fpga/of-fpga-region.c

index caa091224dc54070b4fc6efe989cbd88a571f682..9107a5b461d35fb176e0769ed58762bfc0436c61 100644 (file)
@@ -168,11 +168,10 @@ static int child_regions_with_firmware(struct device_node *overlay)
                                                     fpga_region_of_match);
        }
 
-       of_node_put(child_region);
-
        if (ret)
                pr_err("firmware-name not allowed in child FPGA region: %pOF",
                       child_region);
+       of_node_put(child_region);
 
        return ret;
 }