hte: tegra-194: Fix off by one in tegra_hte_map_to_line_id()
authorDan Carpenter <dan.carpenter@linaro.org>
Wed, 19 Apr 2023 14:30:00 +0000 (17:30 +0300)
committerDipen Patel <dipenp@nvidia.com>
Wed, 26 Apr 2023 22:44:14 +0000 (15:44 -0700)
The "map_sz" is the number of elements in the "m" array so the >
comparison needs to be changed to >= to prevent an out of bounds
read.

Fixes: 09574cca6ad6 ("hte: Add Tegra194 HTE kernel provider")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Acked-by: Dipen Patel <dipenp@nvidia.com>
Signed-off-by: Dipen Patel <dipenp@nvidia.com>
drivers/hte/hte-tegra194.c

index 2c485ff5be2264c74e830420946fe737f59349ba..06ef349a2265e59b7e54f29dc50dc1b084832c27 100644 (file)
@@ -367,7 +367,7 @@ static int tegra_hte_map_to_line_id(u32 eid,
 {
 
        if (m) {
-               if (eid > map_sz)
+               if (eid >= map_sz)
                        return -EINVAL;
                if (m[eid].slice == NV_AON_SLICE_INVALID)
                        return -EINVAL;