diff options
author | Marcelo Araujo <araujo@FreeBSD.org> | 2014-10-24 05:39:32 +0000 |
---|---|---|
committer | Marcelo Araujo <araujo@FreeBSD.org> | 2014-10-24 05:39:32 +0000 |
commit | f695e0468cdd787f778b98f03e3d23cc2e2c1e08 (patch) | |
tree | b8eb1fded5d998a1e2ea24cbea0ab8da509f12c9 | |
parent | bcc63e85863d6cd2560e5cf5120873121f3fcec8 (diff) |
Notes
-rw-r--r-- | sys/dev/uart/uart_subr.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/sys/dev/uart/uart_subr.c b/sys/dev/uart/uart_subr.c index d1e408cba692..26a774cad35b 100644 --- a/sys/dev/uart/uart_subr.c +++ b/sys/dev/uart/uart_subr.c @@ -196,7 +196,7 @@ out: int uart_getenv(int devtype, struct uart_devinfo *di, struct uart_class *class) { - const char *spec; + const char *cp, *spec; bus_addr_t addr = ~0U; int error; @@ -214,12 +214,12 @@ uart_getenv(int devtype, struct uart_devinfo *di, struct uart_class *class) * port (resp). */ if (devtype == UART_DEV_CONSOLE) - spec = kern_getenv("hw.uart.console"); + cp = kern_getenv("hw.uart.console"); else if (devtype == UART_DEV_DBGPORT) - spec = kern_getenv("hw.uart.dbgport"); + cp = kern_getenv("hw.uart.dbgport"); else - spec = NULL; - if (spec == NULL) + cp = NULL; + if (cp == NULL) return (ENXIO); /* Set defaults. */ @@ -232,6 +232,7 @@ uart_getenv(int devtype, struct uart_devinfo *di, struct uart_class *class) di->parity = UART_PARITY_NONE; /* Parse the attributes. */ + spec = cp; while (1) { switch (uart_parse_tag(&spec)) { case UART_TAG_BR: @@ -267,14 +268,18 @@ uart_getenv(int devtype, struct uart_devinfo *di, struct uart_class *class) di->bas.rclk = uart_parse_long(&spec); break; default: + freeenv(__DECONST(char *, cp)); return (EINVAL); } if (*spec == '\0') break; - if (*spec != ',') + if (*spec != ',') { + freeenv(__DECONST(char *, cp)); return (EINVAL); + } spec++; } + freeenv(__DECONST(char *, cp)); /* * If we still have an invalid address, the specification must be |