aboutsummaryrefslogtreecommitdiffstats
path: root/target
diff options
context:
space:
mode:
authorThibaut VARENE <hacks@slashdirt.org>2017-03-13 14:51:54 +0100
committerPiotr Dymacz <pepe2k@gmail.com>2017-03-15 23:00:52 +0100
commite1f3cf7ede923312a09fd37195b059a31072cd52 (patch)
tree24b23be6df0642e89ff6ea8458f8bf0bd481e949 /target
parente3dc036cbf53bb4c2538b619f986cc3cd2aabc87 (diff)
downloadupstream-e1f3cf7ede923312a09fd37195b059a31072cd52.tar.gz
upstream-e1f3cf7ede923312a09fd37195b059a31072cd52.tar.bz2
upstream-e1f3cf7ede923312a09fd37195b059a31072cd52.zip
ar71xx: mikrotik: prepend "RouterBOARD" to machine name for NOR devices
When the device name doesn't already contain "RouterBOARD", this patch adds this string to the machine name. Most NOR devices already have "RouterBOARD" in their hardware-stored device name, but not all of them. This patch also makes the code more robust against buffer overflows. Signed-off-by: Thibaut VARENE <hacks@slashdirt.org>
Diffstat (limited to 'target')
-rw-r--r--target/linux/ar71xx/files/arch/mips/ath79/mach-rbspi.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-rbspi.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-rbspi.c
index b26b1ae46e..3f68b94bcd 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/mach-rbspi.c
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-rbspi.c
@@ -437,20 +437,32 @@ void __init rbspi_wlan_init(u16 id, int wmac_offset)
kfree(art_buf);
}
+#define RBSPI_MACH_BUFLEN 64
/*
* Common platform init routine for all SPI NOR devices.
*/
static int __init rbspi_platform_setup(void)
{
const struct rb_info *info;
- char buf[64];
+ char buf[RBSPI_MACH_BUFLEN] = "MikroTik ";
+ char *str;
+ int len = RBSPI_MACH_BUFLEN - strlen(buf) - 1;
info = rb_init_info((void *)(KSEG1ADDR(AR71XX_SPI_BASE)), 0x20000);
if (!info)
return -ENODEV;
- scnprintf(buf, sizeof(buf), "MikroTik %s",
- (info->board_name) ? info->board_name : "");
+ if (info->board_name) {
+ str = "RouterBOARD ";
+ if (strncmp(info->board_name, str, strlen(str))) {
+ strncat(buf, str, len);
+ len -= strlen(str);
+ }
+ strncat(buf, info->board_name, len);
+ }
+ else
+ strncat(buf, "UNKNOWN", len);
+
mips_set_machine_name(buf);
/* fix partitions based on flash parsing */