Fixes based on the code review
* simplify set_console() * Prevent buffer overflow in fpga_verify() * Set individual temporary MAC addresses in set_mac_address() * Check return value of miiphy_get_current_dev() BugzId: 66150
This commit is contained in:
parent
8efea863e6
commit
2e581d5211
|
|
@ -21,7 +21,7 @@ void set_console(void)
|
||||||
char buf[6];
|
char buf[6];
|
||||||
char consolefile[] = "/root/boot/consoledev";
|
char consolefile[] = "/root/boot/consoledev";
|
||||||
char *defaultconsole = env_get("defaultconsole");
|
char *defaultconsole = env_get("defaultconsole");
|
||||||
int use_default_console = 0;
|
int use_default_console = 1;
|
||||||
|
|
||||||
#if defined(CONFIG_PRE_CONSOLE_BUFFER)
|
#if defined(CONFIG_PRE_CONSOLE_BUFFER)
|
||||||
int len = 0;
|
int len = 0;
|
||||||
|
|
@ -29,25 +29,13 @@ void set_console(void)
|
||||||
read_file_set_blk_dev("mmc", "0:3", FS_TYPE_EXT);
|
read_file_set_blk_dev("mmc", "0:3", FS_TYPE_EXT);
|
||||||
|
|
||||||
len = get_file_size(consolefile);
|
len = get_file_size(consolefile);
|
||||||
if (len>=4) {
|
if (len>=5) {
|
||||||
memset(buf, 0x00, sizeof(buf));
|
memset(buf, 0x00, sizeof(buf));
|
||||||
read_file(consolefile, buf, sizeof(buf)-1);
|
read_file(consolefile, buf, sizeof(buf)-1);
|
||||||
if (strstr(buf, "ttyS")==buf) {
|
if (strstr(buf, "ttyS") == buf && ( buf[4] == '0' || buf[4] == '1' )) {
|
||||||
if ((buf[4]<'0') && (buf[4]>'1')) {
|
|
||||||
/* invalid tty specified */
|
|
||||||
use_default_console = 1;
|
|
||||||
} else {
|
|
||||||
/* Use retrieved ttySx */
|
/* Use retrieved ttySx */
|
||||||
|
use_default_console = 0;
|
||||||
}
|
}
|
||||||
} else if (strstr(buf, "none")==buf) {
|
|
||||||
/* disable console */
|
|
||||||
buf[0] = 0;
|
|
||||||
} else {
|
|
||||||
/* invalid device specified */
|
|
||||||
use_default_console = 1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
use_default_console = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use_default_console) {
|
if (use_default_console) {
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,7 @@ static inline void spi_write(const struct nbhw_fpga_priv *priv, u8 data)
|
||||||
static int fpga_verify(struct nbhw_fpga_priv *priv)
|
static int fpga_verify(struct nbhw_fpga_priv *priv)
|
||||||
{
|
{
|
||||||
/* Check, if the FPGA is working */
|
/* Check, if the FPGA is working */
|
||||||
char fpga_type[30];
|
char fpga_type[128];
|
||||||
u16 signature = readw(priv->regs);
|
u16 signature = readw(priv->regs);
|
||||||
u16 fpga_version = readw(priv->regs + 0x02);
|
u16 fpga_version = readw(priv->regs + 0x02);
|
||||||
u8 fpga_major = (fpga_version >> 8) & 0xFF;
|
u8 fpga_major = (fpga_version >> 8) & 0xFF;
|
||||||
|
|
@ -318,7 +318,7 @@ static void clean_up_after_programming(const struct nbhw_fpga_priv *priv)
|
||||||
writel(0x55555555, MVEBU_MPP_BASE + 0x10);
|
writel(0x55555555, MVEBU_MPP_BASE + 0x10);
|
||||||
writel(0x06605505, MVEBU_MPP_BASE + 0x14);
|
writel(0x06605505, MVEBU_MPP_BASE + 0x14);
|
||||||
|
|
||||||
dm_gpio_set_value(&priv->reset_logic, 0); //TODO : that seems wrong (AO)
|
dm_gpio_set_value(&priv->reset_logic, 0);
|
||||||
udelay(100);
|
udelay(100);
|
||||||
dm_gpio_set_value(&priv->reset_logic, 1);
|
dm_gpio_set_value(&priv->reset_logic, 1);
|
||||||
udelay(100);
|
udelay(100);
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ void set_mac_address(int interface, int mac) {
|
||||||
else {
|
else {
|
||||||
/* make temporary address */
|
/* make temporary address */
|
||||||
macaddress[0] = 0;
|
macaddress[0] = 0;
|
||||||
macaddress[5] += 1;
|
macaddress[5] += interface;
|
||||||
set_mac(interface, macaddress, 6);
|
set_mac(interface, macaddress, 6);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,8 @@ static int check_mvswitch(void)
|
||||||
unsigned short switchPortProductId;
|
unsigned short switchPortProductId;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
|
if (!miidev) goto abort;
|
||||||
|
|
||||||
debug ("miidev: %s\n", miidev);
|
debug ("miidev: %s\n", miidev);
|
||||||
|
|
||||||
res = miiphy_read(miidev, 0x10, 0x03, &switchPortProductId);
|
res = miiphy_read(miidev, 0x10, 0x03, &switchPortProductId);
|
||||||
|
|
@ -54,6 +56,8 @@ static int init_mvswitch(void)
|
||||||
unsigned short page;
|
unsigned short page;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (!miidev) goto abort;
|
||||||
|
|
||||||
debug ("miidev: %s\n", miidev);
|
debug ("miidev: %s\n", miidev);
|
||||||
|
|
||||||
switch (mvSwType)
|
switch (mvSwType)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue