From: Johannes Beisswenger <johannes.beisswenger-QHh2hmjso9JBDgjK7y7TUQ@public.gmane.org>
To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Johannes Beisswenger
<johannes.beisswenger-QHh2hmjso9JBDgjK7y7TUQ@public.gmane.org>
Subject: [PATCH 3/3] checks: Fix crash in graph_child_address if 'reg' cell size > 1
Date: Fri, 28 Apr 2023 15:38:34 +0200 [thread overview]
Message-ID: <20230428133834.78178-3-johannes.beisswenger@cetitec.com> (raw)
In-Reply-To: <20230428133834.78178-1-johannes.beisswenger-QHh2hmjso9JBDgjK7y7TUQ@public.gmane.org>
If an endpoint node has a 'reg' property which consists of more than
one cell and given that matching '#address-cells' and '#size-cells'
properties are specified on the port node an assertion is triggered in
check_graph_child_address() before the relevant diagnostic checks in
check_graph_reg() (called by check_graph_port()) are executed.
Example dts file triggering the issue:
/dts-v1/;
/ {
bar: bar {
port {
bar_con: endpoint {
remote-endpoint = <&foo_con>;
};
};
};
foo {
port {
#address-cells = <1>;
#size-cells = <1>; // should always be 0
foo_con: endpoint@1 {
reg = <1 2>; // causes assertion failure instead of diagnostic
remote-endpoint = <&bar_con>;
};
};
};
};
Signed-off-by: Johannes Beisswenger <johannes.beisswenger-QHh2hmjso9JBDgjK7y7TUQ@public.gmane.org>
---
checks.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/checks.c b/checks.c
index 8ed7a60..4648c44 100644
--- a/checks.c
+++ b/checks.c
@@ -1798,8 +1798,10 @@ static void check_graph_child_address(struct check *c, struct dt_info *dti,
struct property *prop = get_property(child, "reg");
/* No error if we have any non-zero unit address */
- if (prop && propval_cell(prop) != 0)
+ /* We have a check for val.len == sizeof(cell_t) elsewhere */
+ if (prop && propval_cell_n(prop, 0) != 0 ) {
return;
+ }
cnt++;
}
--
2.40.0
prev parent reply other threads:[~2023-04-28 13:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-28 13:38 [PATCH 1/3] checks: Fix segmentation fault in check_graph_node Johannes Beisswenger
[not found] ` <20230428133834.78178-1-johannes.beisswenger-QHh2hmjso9JBDgjK7y7TUQ@public.gmane.org>
2023-04-28 13:38 ` [PATCH 2/3] tests: Add test cases for bad endpoint node and remote-endpoint prop checks Johannes Beisswenger
2023-04-28 13:38 ` Johannes Beisswenger [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230428133834.78178-3-johannes.beisswenger@cetitec.com \
--to=johannes.beisswenger-qhh2hmjso9jbdgjk7y7tuq@public.gmane.org \
--cc=devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).