[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220307141318.GA18867@kili>
Date: Mon, 7 Mar 2022 17:13:18 +0300
From: Dan Carpenter <dan.carpenter@...cle.com>
To: Richard Cochran <richardcochran@...il.com>,
Vadim Fedorenko <vadfed@...com>
Cc: Jonathan Lemon <jonathan.lemon@...il.com>,
"David S. Miller" <davem@...emloft.net>, netdev@...r.kernel.org,
kernel-janitors@...r.kernel.org
Subject: [PATCH net-next] 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@...cle.com>
---
drivers/ptp/ptp_ocp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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];
}
--
2.20.1
Powered by blists - more mailing lists