[Bug 266862] devctl getpath cause panic invoking with root0

From: <bugzilla-noreply_at_freebsd.org>
Date: Thu, 06 Oct 2022 10:50:07 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=266862

--- Comment #2 from Takanori Watanabe <takawata@FreeBSD.org> ---
(In reply to Takanori Watanabe from comment #1)
reverse patch ...
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c
index 041e77259313..487e573451ed 100644
--- a/sys/kern/subr_bus.c
+++ b/sys/kern/subr_bus.c
@@ -5310,9 +5310,13 @@ device_get_path(device_t dev, const char *locator)
        ssize_t len;
        char *rv = NULL;
        int error;
+       device_t parent = device_get_parent(dev);
+
+       if(parent == NULL)
+               return rv;

        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)
                goto out;

-- 
You are receiving this mail because:
You are the assignee for the bug.