git: 8cf783bde353 - main - device_get_path(): handle case when dev is root
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 19 Oct 2022 16:40:02 UTC
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=8cf783bde35352eb6105cefa9fcb586c01b77179 commit 8cf783bde35352eb6105cefa9fcb586c01b77179 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2022-10-06 19:46:30 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2022-10-19 16:39:33 +0000 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 --- sys/kern/subr_bus.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index b083411f9876..74bc47174d8d 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -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);