[][openwrt][mt7988][pce][fix out-of-bound array access]
[Description]
Fix potential out-of-bound array access.
The CDRT can only be accessed within 1 ~ 31 while the CDRT find function's
error checking mechanism is checked the FE_MEM_CDRT_MAX_INDEX which is 96.
Ajust the error checking mechanism so that we can ensure the input is
within 1 ~ 31
[Release-log]
N/A
Change-Id: I85565f16e641800baee6dcfdcf8697ac64625d20
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/8263662
diff --git a/package-21.02/kernel/pce/src/cdrt.c b/package-21.02/kernel/pce/src/cdrt.c
index ae2d742..2600082 100644
--- a/package-21.02/kernel/pce/src/cdrt.c
+++ b/package-21.02/kernel/pce/src/cdrt.c
@@ -124,7 +124,7 @@
unsigned long flag;
u32 idx;
- if (unlikely(!cdrt_idx || cdrt_idx >= FE_MEM_CDRT_MAX_INDEX))
+ if (unlikely(!cdrt_idx || cdrt_idx > CDRT_DEC_MAX_ENTRY + CDRT_ENC_MAX_ENTRY))
return ERR_PTR(-EINVAL);
spin_lock_irqsave(&cdrt_hw.lock, flag);