linux-yocto/drivers/fpga
Qasim Ijaz e69e2cfd8b fpga: fix potential null pointer deref in fpga_mgr_test_img_load_sgt()
[ Upstream commit 6ebf198203 ]

fpga_mgr_test_img_load_sgt() allocates memory for sgt using
kunit_kzalloc() however it does not check if the allocation failed.
It then passes sgt to sg_alloc_table(), which passes it to
__sg_alloc_table(). This function calls memset() on sgt in an attempt to
zero it out. If the allocation fails then sgt will be NULL and the
memset will trigger a NULL pointer dereference.

Fix this by checking the allocation with KUNIT_ASSERT_NOT_ERR_OR_NULL().

Reviewed-by: Marco Pagani <marco.pagani@linux.dev>
Fixes: ccbc1c3021 ("fpga: add an initial KUnit suite for the FPGA Manager")
Signed-off-by: Qasim Ijaz <qasdev00@gmail.com>
Acked-by: Xu Yilun <yilun.xu@intel.com>
Link: https://lore.kernel.org/r/20250422153737.5264-1-qasdev00@gmail.com
Signed-off-by: Xu Yilun <yilun.xu@linux.intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-06-19 15:28:31 +02:00
..
tests
altera-cvp.c
altera-fpga2sdram.c
altera-freeze-bridge.c
altera-hps2fpga.c
altera-pr-ip-core-plat.c
altera-pr-ip-core.c
altera-ps-spi.c
dfl-afu-dma-region.c
dfl-afu-error.c
dfl-afu-main.c
dfl-afu-region.c
dfl-afu.h
dfl-fme-br.c
dfl-fme-error.c
dfl-fme-main.c
dfl-fme-mgr.c
dfl-fme-perf.c
dfl-fme-pr.c
dfl-fme-pr.h
dfl-fme-region.c
dfl-fme.h
dfl-n3000-nios.c
dfl-pci.c
dfl.c
dfl.h
fpga-bridge.c
fpga-mgr.c
fpga-region.c
ice40-spi.c
intel-m10-bmc-sec-update.c
Kconfig
lattice-sysconfig-spi.c
lattice-sysconfig.c
lattice-sysconfig.h
machxo2-spi.c
Makefile
microchip-spi.c
of-fpga-region.c
socfpga-a10.c
socfpga.c
stratix10-soc.c
ts73xx-fpga.c
versal-fpga.c
xilinx-pr-decoupler.c
xilinx-spi.c
zynq-fpga.c
zynqmp-fpga.c