From c11862c030e4aa13688d367521e3988d17c69941 Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Sat, 9 Jun 2018 14:47:49 +0000 Subject: [PATCH] In the ThunderX BGX network driver we were skipping the NULL terminator when parsing the phy type, however this is included in the length returned by OF_getprop. To fix this stop ignoring the terminator. PR: 228828 Reported by: sbruno Sponsored by: DARPA, AFRL --- sys/dev/vnic/thunder_bgx_fdt.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/sys/dev/vnic/thunder_bgx_fdt.c b/sys/dev/vnic/thunder_bgx_fdt.c index c3b0db465edd..86ca4d1a4f1f 100644 --- a/sys/dev/vnic/thunder_bgx_fdt.c +++ b/sys/dev/vnic/thunder_bgx_fdt.c @@ -93,44 +93,44 @@ bgx_fdt_phy_mode_match(struct bgx *bgx, char *qlm_mode, ssize_t size) switch (bgx->qlm_mode) { case QLM_MODE_SGMII: type = "sgmii"; - sz = sizeof("sgmii") - 1; + sz = sizeof("sgmii"); offset = size - sz; break; case QLM_MODE_XAUI_1X4: type = "xaui"; - sz = sizeof("xaui") - 1; + sz = sizeof("xaui"); offset = size - sz; if (offset < 0) return (FALSE); if (strncmp(&qlm_mode[offset], type, sz) == 0) return (TRUE); type = "dxaui"; - sz = sizeof("dxaui") - 1; + sz = sizeof("dxaui"); offset = size - sz; break; case QLM_MODE_RXAUI_2X2: type = "raui"; - sz = sizeof("raui") - 1; + sz = sizeof("raui"); offset = size - sz; break; case QLM_MODE_XFI_4X1: type = "xfi"; - sz = sizeof("xfi") - 1; + sz = sizeof("xfi"); offset = size - sz; break; case QLM_MODE_XLAUI_1X4: type = "xlaui"; - sz = sizeof("xlaui") - 1; + sz = sizeof("xlaui"); offset = size - sz; break; case QLM_MODE_10G_KR_4X1: type = "xfi-10g-kr"; - sz = sizeof("xfi-10g-kr") - 1; + sz = sizeof("xfi-10g-kr"); offset = size - sz; break; case QLM_MODE_40G_KR4_1X4: type = "xlaui-40g-kr"; - sz = sizeof("xlaui-40g-kr") - 1; + sz = sizeof("xlaui-40g-kr"); offset = size - sz; break; default: @@ -155,37 +155,37 @@ bgx_fdt_phy_name_match(struct bgx *bgx, char *phy_name, ssize_t size) switch (bgx->qlm_mode) { case QLM_MODE_SGMII: type = "sgmii"; - sz = sizeof("sgmii") - 1; + sz = sizeof("sgmii"); break; case QLM_MODE_XAUI_1X4: type = "xaui"; - sz = sizeof("xaui") - 1; + sz = sizeof("xaui"); if (sz < size) return (FALSE); if (strncmp(phy_name, type, sz) == 0) return (TRUE); type = "dxaui"; - sz = sizeof("dxaui") - 1; + sz = sizeof("dxaui"); break; case QLM_MODE_RXAUI_2X2: type = "raui"; - sz = sizeof("raui") - 1; + sz = sizeof("raui"); break; case QLM_MODE_XFI_4X1: type = "xfi"; - sz = sizeof("xfi") - 1; + sz = sizeof("xfi"); break; case QLM_MODE_XLAUI_1X4: type = "xlaui"; - sz = sizeof("xlaui") - 1; + sz = sizeof("xlaui"); break; case QLM_MODE_10G_KR_4X1: type = "xfi-10g-kr"; - sz = sizeof("xfi-10g-kr") - 1; + sz = sizeof("xfi-10g-kr"); break; case QLM_MODE_40G_KR4_1X4: type = "xlaui-40g-kr"; - sz = sizeof("xlaui-40g-kr") - 1; + sz = sizeof("xlaui-40g-kr"); break; default: return (FALSE);