Fix device lookup of for the stdout-path chosen property.

The stdout-path chosen property may include the serial connection details,
e.g. the baud rate. When passing the device to OF_finddevice we need to
strip off this information as it will cause the lookup to fail.

Reviewed by:	emaste, manu
Differential Revision:	https://reviews.freebsd.org/D6846
This commit is contained in:
andrew 2017-06-02 14:01:17 +00:00
parent be6866f094
commit bdde50ae95

View File

@ -117,9 +117,18 @@ static int
phandle_chosen_propdev(phandle_t chosen, const char *name, phandle_t *node)
{
char buf[64];
char *sep;
if (OF_getprop(chosen, name, buf, sizeof(buf)) <= 0)
return (ENXIO);
/*
* stdout-path may have a ':' to separate the device from the
* connection settings. Split the string so we just pass the former
* to OF_finddevice.
*/
sep = strchr(buf, ':');
if (sep != NULL)
*sep = '\0';
if ((*node = OF_finddevice(buf)) == -1)
return (ENXIO);