summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Holland <[email protected]>2025-02-13 14:48:38 -0800
committerAnup Patel <[email protected]>2025-02-19 18:22:52 +0530
commitf95d1140f61d4afdd922379bff40edf8556c64e4 (patch)
tree50321cd265dd39f693472f5c3b2fb1b98aa71bc1
parent38df94422b68cb9e20ad19a507fc91ac10c20b14 (diff)
lib: utils/fdt: Remove redundant PMU property length checks
If a property value is too small, len will be zero after the division on the next line, so the property will be ignored. This is the same behavior as when the length check fails. Furthermore, the first two length checks were already ineffectual, because each item in those arrays is 12 bytes long, not 8. Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Anup Patel <[email protected]>
-rw-r--r--lib/utils/fdt/fdt_pmu.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/utils/fdt/fdt_pmu.c b/lib/utils/fdt/fdt_pmu.c
index 64de569e..22760603 100644
--- a/lib/utils/fdt/fdt_pmu.c
+++ b/lib/utils/fdt/fdt_pmu.c
@@ -74,7 +74,7 @@ int fdt_pmu_setup(const void *fdt)
event_ctr_map = fdt_getprop(fdt, pmu_offset,
"riscv,event-to-mhpmcounters", &len);
- if (event_ctr_map && len >= 8) {
+ if (event_ctr_map) {
len = len / (sizeof(u32) * 3);
for (i = 0; i < len; i++) {
event_idx_start = fdt32_to_cpu(event_ctr_map[3 * i]);
@@ -89,7 +89,7 @@ int fdt_pmu_setup(const void *fdt)
event_val = fdt_getprop(fdt, pmu_offset,
"riscv,event-to-mhpmevent", &len);
- if (event_val && len >= 8) {
+ if (event_val) {
len = len / (sizeof(u32) * 3);
for (i = 0; i < len; i++) {
event = &fdt_pmu_evt_select[hw_event_count];
@@ -103,7 +103,7 @@ int fdt_pmu_setup(const void *fdt)
event_val = fdt_getprop(fdt, pmu_offset,
"riscv,raw-event-to-mhpmcounters", &len);
- if (event_val && len >= 20) {
+ if (event_val) {
len = len / (sizeof(u32) * 5);
for (i = 0; i < len; i++) {
raw_selector = fdt32_to_cpu(event_val[5 * i]);