From: David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>
To: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Andre Przywara <andre.przywara-5wv7dgnIgG8@public.gmane.org>
Subject: Re: [PATCH v2 5/5] checks: Add a sanity check for #.*-cells property value
Date: Thu, 14 Oct 2021 14:50:50 +1100 [thread overview]
Message-ID: <YWepGobgyydk3T2i@yekko> (raw)
In-Reply-To: <20211011191245.1009682-5-robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 1757 bytes --]
On Mon, Oct 11, 2021 at 02:12:45PM -0500, Rob Herring wrote:
> While in theory any value of number of cells is allowed for a #.*-cells
> property, for all practical purposes the number of cells is never more than
> a few cells. Add a check that the value is less than 255. This will catch
> cases like this which will currently pass:
>
> #foo-cells = "bar";
>
> Signed-off-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Hmm. So the original idea was that this helper could be used for any
1-cell property, not just for #foo-cells. In practice we're only
using it for #foo-cells so far.
The change would be ok if we updated the names to make it clearer that
this is specifically for #foo-cells properties, not anything else.
> ---
> checks.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/checks.c b/checks.c
> index 903083bfc423..467442250eda 100644
> --- a/checks.c
> +++ b/checks.c
> @@ -260,8 +260,14 @@ static void check_is_cell(struct check *c, struct dt_info *dti,
> if (!prop)
> return; /* Not present, assumed ok */
>
> - if (prop->val.len != sizeof(cell_t))
> + if (prop->val.len != sizeof(cell_t)) {
> FAIL_PROP(c, dti, node, prop, "property is not a single cell");
> + return;
> + }
> +
> + /* Sanity test for reasonable number of cells */
> + if (propval_cell(prop) > 255)
> + FAIL_PROP(c, dti, node, prop, "cell size out of range (>255)");
> }
> #define WARNING_IF_NOT_CELL(nm, propname) \
> WARNING(nm, check_is_cell, (propname))
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2021-10-14 3:50 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-11 19:12 [PATCH v2 1/5] checks: Make interrupt_provider check dependent on interrupts_extended_is_cell Rob Herring
[not found] ` <20211011191245.1009682-1-robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2021-10-11 19:12 ` [PATCH v2 2/5] checks: Add an interrupt-map check Rob Herring
[not found] ` <20211011191245.1009682-2-robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2021-10-14 3:44 ` David Gibson
2021-10-11 19:12 ` [PATCH v2 3/5] checks: Drop interrupt provider '#address-cells' check Rob Herring
[not found] ` <20211011191245.1009682-3-robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2021-10-14 3:45 ` David Gibson
2021-10-11 19:12 ` [PATCH v2 4/5] checks: Ensure '#interrupt-cells' only exists in interrupt providers Rob Herring
[not found] ` <20211011191245.1009682-4-robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2021-10-14 3:46 ` David Gibson
2021-10-15 18:43 ` Rob Herring
[not found] ` <CAL_JsqLT3FKtaFxTmWU=Y5_D=EyP=L_Aouij2Qw7MKOJ+RY-HQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2021-10-15 19:28 ` Rob Herring
2021-10-11 19:12 ` [PATCH v2 5/5] checks: Add a sanity check for #.*-cells property value Rob Herring
[not found] ` <20211011191245.1009682-5-robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2021-10-14 3:50 ` David Gibson [this message]
2021-10-14 3:41 ` [PATCH v2 1/5] checks: Make interrupt_provider check dependent on interrupts_extended_is_cell David Gibson
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=YWepGobgyydk3T2i@yekko \
--to=david-xt8fgy+axnrb3ne2bgzf6laj5h9x9tb+@public.gmane.org \
--cc=andre.przywara-5wv7dgnIgG8@public.gmane.org \
--cc=devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=robh-DgEjT+Ai2ygdnm+yROfE0A@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 NNTP newsgroup(s).