From nobody Wed Oct 19 16:40:02 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MsxKZ2q0mz4gMyb; Wed, 19 Oct 2022 16:40:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MsxKZ2L1hz3clh; Wed, 19 Oct 2022 16:40:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666197602; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=pXmZ25lGqplEn0KgVe1njtF467jMnMOXqG007alhono=; b=UfUltZz7Nto5Bve3Oqc+tFpC5a0A99K3xldssnp8CAeBKa1A82LhiIX4Wc9IwM8/VFzh8N MY6UNYZ0zZAK4OCnKsgYMFRiGIzvGuH0O2kZq13dmjF8aLXNy3IAFNlKuc73Vys0zkOlv8 3Kx6EeHqPRxFVg/I0Ed38GPqx755mIdBmzyrk71rOIckJUy+Sihcx4j3EJB5KT+9Hb9n92 MjSnFRCBcdIKheAjhFNwboLUn0G5y/NJqtN2QviTdlrkKEn9MBSyBIxVyCmafvzcO8Rs18 WNidrftr5vv5ZG7N6b7tVNSCUonbhtdCyPVTMOJrQpYd2f9v9cPoCgO5PIxcKQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MsxKZ1LsZzbLC; Wed, 19 Oct 2022 16:40:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 29JGe2n4014038; Wed, 19 Oct 2022 16:40:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29JGe2uj014036; Wed, 19 Oct 2022 16:40:02 GMT (envelope-from git) Date: Wed, 19 Oct 2022 16:40:02 GMT Message-Id: <202210191640.29JGe2uj014036@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 8cf783bde353 - main - device_get_path(): handle case when dev is root List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8cf783bde35352eb6105cefa9fcb586c01b77179 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666197602; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=pXmZ25lGqplEn0KgVe1njtF467jMnMOXqG007alhono=; b=V6S1ZRywXFLswpX/yxqpGE6yDazy1slXNk84/7UJg30cB08Nzg89m+tLdwq9pfwBim2zOx NmUDcT0HVPw/bEWF2O9Q2rPQB8SIF3p6j+pyuXD13q3Fdm0zxV7HkXYoZhFA3rPa3kjViD bC9ZeAROI6encc/gNvnerEc7squqoEGiWJUphW8wUDGbjKSndR0LY5NG/7ZXVkm88Bhd6l 7z2keB4CvsFvC8sLt9o6hUk0Xa8WfYX+Pf6NskKl35IUsoz4gWGlcnhWNB14Kn/HDOKpvQ OS++iHP4a1kgKSmcl+pN9kRHCGZa5qXLkNW5bLA8NU7NnweaO3mRq7FRiVieQA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1666197602; a=rsa-sha256; cv=none; b=iuFHE8tL3CxNR4VsOhS4Bl3KIMC+/j4c4NW04LL5ULG/gj1UhvEh1b0bBghqsCxknfn9kA OoBwKHE3qUt8hPohugEaum37RFx5T48guVQnzrsUQJ5IjHXMhiKW8yTRy0xoZIi1s7AToR aK8mRMkUp4E+6jQtm201c7rO1Rlr4NqnV5vY8TansOp94a+RxRnE2FDFXNhQJvHVknay3w LgI2PYaaPhsPH0yjNTpODL1SWXlQocJAhaNKJXkKjf32ddaILxZyT6WxcBl6H4hdwaXZ+E OXDgCF+IzMVqr+vCBoeP7Y/2byPX2KYSljx8W5u75Sd52czLjBS83vPyHoZ4vQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=8cf783bde35352eb6105cefa9fcb586c01b77179 commit 8cf783bde35352eb6105cefa9fcb586c01b77179 Author: Konstantin Belousov AuthorDate: 2022-10-06 19:46:30 +0000 Commit: Konstantin Belousov 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);