Commit 72f00505 authored by Dan Carpenter's avatar Dan Carpenter Committed by Jakub Kicinski

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: 9f492c4c ("ptp: ocp: add TOD debug information")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Acked-by: default avatarRichard Cochran <richardcochran@gmail.com>
Acked-by: default avatarJonathan Lemon <jonathan.lemon@gmail.com>
Link: https://lore.kernel.org/r/20220307141318.GA18867@kiliSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 57d29a29
......@@ -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];
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment