[PATCH 8/9] bsps/xnandpsu: Constrain block erasure to device

Kinsey Moore kinsey.moore at oarcorp.com
Sat Dec 9 02:31:25 UTC 2023


The XNandPsu_EraseBlock function takes a target device and a block
offset for erasure. Ensure the block offset is within the size of the
target device.
---
 bsps/shared/dev/nand/xnandpsu.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/bsps/shared/dev/nand/xnandpsu.c b/bsps/shared/dev/nand/xnandpsu.c
index db4e625e5a..65c58b7e9b 100644
--- a/bsps/shared/dev/nand/xnandpsu.c
+++ b/bsps/shared/dev/nand/xnandpsu.c
@@ -2193,7 +2193,11 @@ s32 XNandPsu_EraseBlock(XNandPsu *InstancePtr, u32 Target, u32 Block)
 	Xil_AssertNonvoid(InstancePtr != NULL);
 	Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
 	Xil_AssertNonvoid(Target < XNANDPSU_MAX_TARGETS);
+#ifdef __rtems__
+	Xil_AssertNonvoid(Block < InstancePtr->Geometry.NumTargetBlocks);
+#else
 	Xil_AssertNonvoid(Block < InstancePtr->Geometry.NumBlocks);
+#endif
 
 	s32 Status = XST_FAILURE;
 	u32 Page;
-- 
2.39.2



More information about the devel mailing list