summaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/marvell/sky2.c
diff options
context:
space:
mode:
authorAndrew Lunn <andrew@lunn.ch>2020-11-10 03:32:22 +0100
committerJakub Kicinski <kuba@kernel.org>2020-11-12 02:42:24 +0100
commit0575bedd6a1575e3f585b5dd5621cdcd26978054 (patch)
tree0f38954163869f6ac2fa910eb19f60b1a468b216 /drivers/net/ethernet/marvell/sky2.c
parentMAINTAINERS: Add entry for Hirschmann Hellcreek Switch Driver (diff)
downloadlinux-0575bedd6a1575e3f585b5dd5621cdcd26978054.tar.xz
linux-0575bedd6a1575e3f585b5dd5621cdcd26978054.zip
drivers: net: sky2: Fix -Wstringop-truncation with W=1
In function ‘strncpy’, inlined from ‘sky2_name’ at drivers/net/ethernet/marvell/sky2.c:4903:3, inlined from ‘sky2_probe’ at drivers/net/ethernet/marvell/sky2.c:5049:2: ./include/linux/string.h:297:30: warning: ‘__builtin_strncpy’ specified bound 16 equals destination size [-Wstringop-truncation] None of the device names are 16 characters long, so it was never an issue. But replace the strncpy with an snprintf() to prevent the theoretical overflow. Suggested-by: Stephen Hemminger <stephen@networkplumber.org> Signed-off-by: Andrew Lunn <andrew@lunn.ch> Acked-by: Stephen Hemminger <stephen@networkplumber.org> Link: https://lore.kernel.org/r/20201110023222.1479398-1-andrew@lunn.ch Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'drivers/net/ethernet/marvell/sky2.c')
-rw-r--r--drivers/net/ethernet/marvell/sky2.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/net/ethernet/marvell/sky2.c b/drivers/net/ethernet/marvell/sky2.c
index 25981a7a43b5..ebe1406c6e64 100644
--- a/drivers/net/ethernet/marvell/sky2.c
+++ b/drivers/net/ethernet/marvell/sky2.c
@@ -4900,7 +4900,7 @@ static const char *sky2_name(u8 chipid, char *buf, int sz)
};
if (chipid >= CHIP_ID_YUKON_XL && chipid <= CHIP_ID_YUKON_OP_2)
- strncpy(buf, name[chipid - CHIP_ID_YUKON_XL], sz);
+ snprintf(buf, sz, "%s", name[chipid - CHIP_ID_YUKON_XL]);
else
snprintf(buf, sz, "(chip %#x)", chipid);
return buf;