Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 06 Oct 2022 10:49:25 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 266862] devctl getpath cause panic invoking with root0
Message-ID:  <bug-266862-227-gRPBgUYlUp@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-266862-227@https.bugs.freebsd.org/bugzilla/>
References:  <bug-266862-227@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D266862

--- Comment #1 from Takanori Watanabe <takawata@FreeBSD.org> ---
The code was not be compiled. Correct code is as follows.=20
With this patch,=20
% devctl devpath FreeBSD root0
does not cause panic and show error message, as I expected.
devctl: Failed to get path via FreeBSD to root0: Cannot allocate memory


diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c
index 487e573451ed..041e77259313 100644
--- a/sys/kern/subr_bus.c
+++ b/sys/kern/subr_bus.c
@@ -5310,13 +5310,9 @@ device_get_path(device_t dev, const char *locator)
        ssize_t len;
        char *rv =3D NULL;
        int error;
-       device_t parent =3D device_get_parent(dev);
-
-       if(parent =3D=3D NULL)
-               return rv;

        sb =3D sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND | SBUF_INCLUDENUL);
-       error =3D BUS_GET_DEVICE_PATH(parent, dev, locator, sb);
+       error =3D BUS_GET_DEVICE_PATH(device_get_parent(dev), dev, locator,=
 sb);
        sbuf_finish(sb);        /* Note: errors checked with sbuf_len() bel=
ow
*/
        if (error !=3D 0)
                goto out;

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-266862-227-gRPBgUYlUp>