[rtems commit] bsps/xnandpsu: Constrain block erasure to device

Joel Sherrill joel at rtems.org
Thu Dec 14 19:11:58 UTC 2023


Module:    rtems
Branch:    master
Commit:    437053282dbaf4514081ddccd56cdf68410c85fa
Changeset: http://git.rtems.org/rtems/commit/?id=437053282dbaf4514081ddccd56cdf68410c85fa

Author:    Kinsey Moore <kinsey.moore at oarcorp.com>
Date:      Sat Dec  2 20:32:45 2023 -0600

bsps/xnandpsu: Constrain block erasure to device

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;



More information about the vc mailing list