device_get_path(): handle case when dev is root
PR: 266862 Based on submission by: takawata Reviewed by: jhb, takawata Disscussed with: imp Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D36899
This commit is contained in:
parent
d9c5a9ea49
commit
8cf783bde3
@ -5309,11 +5309,17 @@ device_get_path(device_t dev, const char *locator, char **rvp)
|
||||
{
|
||||
struct sbuf *sb;
|
||||
char *s;
|
||||
device_t parent;
|
||||
ssize_t len;
|
||||
int error;
|
||||
|
||||
parent = device_get_parent(dev);
|
||||
if (parent == NULL) {
|
||||
*rvp = strdup_flags("/", M_BUS, M_NOWAIT);
|
||||
return (*rvp == NULL ? ENOMEM : 0);
|
||||
}
|
||||
sb = sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND | SBUF_INCLUDENUL);
|
||||
error = BUS_GET_DEVICE_PATH(device_get_parent(dev), dev, locator, sb);
|
||||
error = BUS_GET_DEVICE_PATH(parent, dev, locator, sb);
|
||||
sbuf_finish(sb); /* Note: errors checked with sbuf_len() below */
|
||||
if (error == 0) {
|
||||
len = sbuf_len(sb);
|
||||
|
Loading…
Reference in New Issue
Block a user