Skip to content

Commit

Permalink
ptp: ocp: off by in in ptp_ocp_tod_gnss_name()
Browse files Browse the repository at this point in the history
The > ARRAY_SIZE() needs to be >= ARRAY_SIZE() to prevent an out of
bounds access.

Fixes: 9f492c4 ("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>
  • Loading branch information
Dan Carpenter authored and Jakub Kicinski committed Mar 7, 2022
1 parent 57d29a2 commit 72f0050
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/ptp/ptp_ocp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down

0 comments on commit 72f0050

Please sign in to comment.