Commit e69e2cfd authored by Qasim Ijaz's avatar Qasim Ijaz Committed by Greg Kroah-Hartman
Browse files

fpga: fix potential null pointer deref in fpga_mgr_test_img_load_sgt()



[ Upstream commit 6ebf1982 ]

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: default avatarMarco Pagani <marco.pagani@linux.dev>
Fixes: ccbc1c30 ("fpga: add an initial KUnit suite for the FPGA Manager")
Signed-off-by: default avatarQasim Ijaz <qasdev00@gmail.com>
Acked-by: default avatarXu Yilun <yilun.xu@intel.com>
Link: https://lore.kernel.org/r/20250422153737.5264-1-qasdev00@gmail.com


Signed-off-by: default avatarXu Yilun <yilun.xu@linux.intel.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 32b3f338
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment