From nobody Mon Mar 11 21:23:29 2024 X-Original-To: dev-commits-src-all@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 4TtqWj5k7Vz5DlFC; Mon, 11 Mar 2024 21:23:29 +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 4TtqWj311xz41QF; Mon, 11 Mar 2024 21:23:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1710192209; 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=Bpx44nnydK3F8rAx2pq7mtCglq2zGNsizL8SmBaJ8y8=; b=GqU541Lg2L14wBnKQ5L946RP57r3pNdaiKtqckndcUYo+elDo8L9f7z1S7JjDDPuxEeEsr whBR25ZYow35ezSOy54FmTb9nywnxEjIvGBOMeruvVzmZPBEZkwW0TG9uOOpjAbLzUZiZm 7oAHuc0uXKws4faAEtYXQQ+EnCKAjAqkVZYyc9ItVFQESD/lNLiDZGuKXPKQ2wR4hM7XOe qoXsDHNijAxrmOqTFfkRd+Ja9dzd9Fu6bkj0aEjUIeH+A92VhTKYOBPbT/5gBGq8WQxVOq n7gq91DAu4hnkh+4Cf1IYcNW4218peMe3ylkpMSvtSDKQSTCb9gZtwxdCr4y3A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1710192209; a=rsa-sha256; cv=none; b=Kso6k1q0k+ABZuuESYNBJTwIFZ5wl70BNtU4PWO0ZJ5MGCGO1/+xAcYODGiYpuRndkNXkO HZb1ieejLh3FouO/AkWZSM9zPNZHUpzAGs4jmbhjKI0w91cMKEjUoYov9sHnNEtqU9hFKT gzRjAruZtX+vY/HTQ8D4vyLIyaC7XCVXFyVIehLmwc251ReBdF5i7tL6/Trlel+1flVdiJ WDu/pqEtcBRScn3TM8/Cxpkb2leyR+M23LETdpNtvL+Lv7zFf6SLoUIxcDTdtOJN0knDxk /Zt8HSUDvdYzbcYAGwKxRtxMXV6hWzklga/zaFAivTTjM6l0akwRk3ADYONBJQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1710192209; 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=Bpx44nnydK3F8rAx2pq7mtCglq2zGNsizL8SmBaJ8y8=; b=KDja19wwOf4X7ayIOatlUlrYYuMXtdSIdJhas1iymOGhJbnm5VsyNsWzlzxhnMiAyPR8yk RtL945RH3j/HeF49AkLvWFBemmNYizG07/bfT0xgaXHL5mSohDcrd0iuTwelkJL3k+jyeA A1FKdi3E4mSYhgKc0vzFYmETkulfJzwAbgZBP+Av4XMifDFJkjnCOeWK5F4FUndbpv0YEc 5MEkiiEy62BZ/IxegI/ROqUhqEFq8mz65g5ouQ8sKeN/rOxywcgGmiPF5WGR6EId03fbZm IhyUjnq+ft1bc1hZXfp1HMndiTVfEm2PqaE+xUCI469WQEOCKrbWtw1mPspleA== 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 4TtqWj26TLzmWK; Mon, 11 Mar 2024 21:23:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 42BLNTvv025720; Mon, 11 Mar 2024 21:23:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 42BLNTLf025717; Mon, 11 Mar 2024 21:23:29 GMT (envelope-from git) Date: Mon, 11 Mar 2024 21:23:29 GMT Message-Id: <202403112123.42BLNTLf025717@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 462af7676b3e - main - kboot: kbootfdt: fix error handling List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 462af7676b3ee8a8bd9ee9b55a35c0cf815a351f Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=462af7676b3ee8a8bd9ee9b55a35c0cf815a351f commit 462af7676b3ee8a8bd9ee9b55a35c0cf815a351f Author: Warner Losh AuthorDate: 2024-03-11 20:15:44 +0000 Commit: Warner Losh CommitDate: 2024-03-11 21:21:52 +0000 kboot: kbootfdt: fix error handling If we are able to open /sys/firmware/fdt, but aren't able to read it, fall back to /proc/device-tree. Remove comment that's not really true, it turns out. Sponsored by: Netflix --- stand/kboot/kboot/kbootfdt.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/stand/kboot/kboot/kbootfdt.c b/stand/kboot/kboot/kbootfdt.c index 70844820d345..e4c378423585 100644 --- a/stand/kboot/kboot/kbootfdt.c +++ b/stand/kboot/kboot/kbootfdt.c @@ -91,22 +91,21 @@ fdt_platform_load_dtb(void) { void *buffer; size_t buflen = 409600; - int fd; + int fd, err = 0; /* * Should load /sys/firmware/fdt if it exists, otherwise we walk the * tree from /proc/device-tree. The former is much easier than the * latter and also the newer interface. But as long as we support the - * PS3 boot, we'll need the latter due to that kernel's age. It likely - * would be better to script the decision between the two, but that - * turns out to be tricky... + * PS3 boot, we'll need the latter due to that kernel's age. */ buffer = malloc(buflen); fd = host_open("/sys/firmware/fdt", O_RDONLY, 0); - if (fd != -1) { - buflen = host_read(fd, buffer, buflen); + if (fd >= 0) { + err = host_read(fd, buffer, buflen); close(fd); - } else { + } + if (fd < 0 || err < 0) { fdt_create_empty_tree(buffer, buflen); add_node_to_fdt(buffer, "/proc/device-tree", fdt_path_offset(buffer, "/"));