diff mbox series

[net-next] ptp: ocp: off by in in ptp_ocp_tod_gnss_name()

Message ID 20220307141318.GA18867@kili (mailing list archive)
State Accepted
Commit 72f00505f2d2eced9789e98ca081f8229f03b2ed
Delegated to: Netdev Maintainers
Headers show
Series [net-next] ptp: ocp: off by in in ptp_ocp_tod_gnss_name() | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Dan Carpenter March 7, 2022, 2:13 p.m. UTC
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>
---
 drivers/ptp/ptp_ocp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Richard Cochran March 7, 2022, 2:16 p.m. UTC | #1
On Mon, Mar 07, 2022 at 05:13:18PM +0300, Dan Carpenter wrote:
> 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>
Jonathan Lemon March 7, 2022, 5:07 p.m. UTC | #2
On Mon, Mar 07, 2022 at 05:13:18PM +0300, Dan Carpenter wrote:
> 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: Jonathan Lemon <jonathan.lemon@gmail.com>
patchwork-bot+netdevbpf@kernel.org March 7, 2022, 11:30 p.m. UTC | #3
Hello:

This patch was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Mon, 7 Mar 2022 17:13:18 +0300 you wrote:
> 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>
> ---
>  drivers/ptp/ptp_ocp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Here is the summary with links:
  - [net-next] ptp: ocp: off by in in ptp_ocp_tod_gnss_name()
    https://git.kernel.org/netdev/net-next/c/72f00505f2d2

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index 608d1a0eb141..300de2ff5657 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];
 }