summaryrefslogtreecommitdiff
path: root/drivers/ptp
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2022-03-07 17:13:18 +0300
committerJakub Kicinski <kuba@kernel.org>2022-03-07 15:12:05 -0800
commit72f00505f2d2eced9789e98ca081f8229f03b2ed (patch)
treefb472a56c54fb7d3fe43cef3a07518107e81aee2 /drivers/ptp
parent57d29a2935c9aab0aaef6264bf6a58aad3859e7c (diff)
ptp: ocp: off by in in ptp_ocp_tod_gnss_name()
The > ARRAY_SIZE() needs to be >= ARRAY_SIZE() to prevent an out of bounds access. Fixes: 9f492c4cb235 ("ptp: ocp: add TOD debug information") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Acked-by: Richard Cochran <richardcochran@gmail.com> Acked-by: Jonathan Lemon <jonathan.lemon@gmail.com> Link: https://lore.kernel.org/r/20220307141318.GA18867@kili Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'drivers/ptp')
-rw-r--r--drivers/ptp/ptp_ocp.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index aaefca6c2422..334435e77b2f 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -914,7 +914,7 @@ ptp_ocp_tod_gnss_name(int idx)
"ALL", "COMBINED", "GPS", "GLONASS", "GALILEO", "BEIDOU",
"Unknown"
};
- if (idx > ARRAY_SIZE(gnss_name))
+ if (idx >= ARRAY_SIZE(gnss_name))
idx = ARRAY_SIZE(gnss_name) - 1;
return gnss_name[idx];
}