Date: Thu, 06 Oct 2022 06:17:48 +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@https.bugs.freebsd.org/bugzilla/>
index | next in thread | raw e-mail
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=266862 Bug ID: 266862 Summary: devctl getpath cause panic invoking with root0 Product: Base System Version: CURRENT Hardware: Any OS: Any Status: New Severity: Affects Many People Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: takawata@FreeBSD.org Invoking % devctl devpath FreeBSD root0 cause kernel panic This may because parent of "root0" device is NULL and invoking BUS_GET_DEVICE_PATH(device_get_parent(dev), dev, locator, sb); references NULL pointer. So check before invoking it. Following code is not tested yet. diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index 041e77259313..92447f825643 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 EINVAL; 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.home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-266862-227>
