From: Alexander Sverdlin <alexander.sverdlin@nsn.com>
To: ext Pantelis Antoniou <panto@antoniou-consulting.com>,
Grant Likely <grant.likely@secretlab.ca>
Cc: Rob Herring <robherring2@gmail.com>,
Stephen Warren <swarren@wwwdotorg.org>,
Matt Porter <matt.porter@linaro.org>,
Koen Kooi <koen@dominion.thruhere.net>,
Alison Chaiken <Alison_Chaiken@mentor.com>,
Dinh Nguyen <dinh.linux@gmail.com>, Jan Lubbe <jluebbe@lasnet.de>,
Michael Stickel <ms@mycable.de>,
Guenter Roeck <linux@roeck-us.net>,
Dirk Behme <dirk.behme@gmail.com>,
Alan Tull <delicious.quinoa@gmail.com>,
Sascha Hauer <s.hauer@pengutronix.de>,
Michael Bohan <mbohan@codeaurora.org>,
Ionut Nicu <ioan.nicu.ext@nsn.com>,
Michal Simek <monstr@monstr.eu>,
Matt Ranostay <mranostay@gmail.com>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 5/5] OF: Introduce utility helper functions
Date: Fri, 08 Nov 2013 10:08:04 +0100 [thread overview]
Message-ID: <527CA9F4.9080003@nsn.com> (raw)
In-Reply-To: <1383855454-15191-6-git-send-email-panto@antoniou-consulting.com>
Hello Pantelis,
On 07/11/13 21:17, ext Pantelis Antoniou wrote:
> Introduce helper functions for working with the live DT tree.
>
> __of_free_property() frees a dynamically created property
> __of_free_tree() recursively frees a device node tree
> __of_copy_property() copies a property dynamically
> __of_create_empty_node() creates an empty node
> __of_find_node_by_full_name() finds the node with the full name
> and
> of_multi_prop_cmp() performs a multi property compare but without
> having to take locks.
>
> Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com>
> ---
> drivers/of/Makefile | 2 +-
> drivers/of/util.c | 253 ++++++++++++++++++++++++++++++++++++++++++++++++++++
> include/linux/of.h | 59 ++++++++++++
> 3 files changed, 313 insertions(+), 1 deletion(-)
> create mode 100644 drivers/of/util.c
>
...
> +struct property *__of_copy_property(const struct property *prop, gfp_t flags)
> +{
> + struct property *propn;
> +
> + propn = kzalloc(sizeof(*prop), flags);
> + if (propn == NULL)
> + return NULL;
> +
> + propn->name = kstrdup(prop->name, flags);
> + if (propn->name == NULL)
> + goto err_fail_name;
> +
> + if (prop->length > 0) {
^^^^^^^^^^^^^^^^^^^^^^^
As Ioan already mentioned, this is really a problem.
There is a bunch of places, where properties without values are used.
Like gpio-controller; ranges; interrupt-controller;
Refer, for example, to of_irq_map_raw() which checks
of_get_property(ipar, "interrupt-controller", NULL) != NULL
and some other occurrences of exactly same construct.
This will simply be broken for merged device-tree parts.
> + propn->value = kmalloc(prop->length, flags);
> + if (propn->value == NULL)
> + goto err_fail_value;
> + memcpy(propn->value, prop->value, prop->length);
> + propn->length = prop->length;
> + }
> +
> + /* mark the property as dynamic */
> + of_property_set_flag(propn, OF_DYNAMIC);
> +
> + return propn;
> +
> +err_fail_value:
> + kfree(propn->name);
> +err_fail_name:
> + kfree(propn);
> + return NULL;
> +}
> +
...
--
Best regards,
Alexander Sverdlin.
next prev parent reply other threads:[~2013-11-08 9:08 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-07 20:17 [PATCH v3 0/5] OF: Fixes in preperation of DT overlays Pantelis Antoniou
2013-11-07 20:17 ` [PATCH v3 1/5] OF: Introduce device tree node flag helpers Pantelis Antoniou
2013-11-07 20:17 ` [PATCH v3 2/5] OF: Clear detach flag on attach Pantelis Antoniou
2013-11-07 20:17 ` [PATCH v3 3/5] OF: export of_property_notify Pantelis Antoniou
2013-11-07 20:17 ` [PATCH v3 4/5] OF: Export all DT proc update functions Pantelis Antoniou
2013-11-07 20:17 ` [PATCH v3 5/5] OF: Introduce utility helper functions Pantelis Antoniou
2013-11-08 9:08 ` Alexander Sverdlin [this message]
2013-11-08 14:54 ` Guenter Roeck
2013-11-08 15:01 ` Alexander Sverdlin
2013-11-08 15:01 ` Pantelis Antoniou
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=527CA9F4.9080003@nsn.com \
--to=alexander.sverdlin@nsn.com \
--cc=Alison_Chaiken@mentor.com \
--cc=delicious.quinoa@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=dinh.linux@gmail.com \
--cc=dirk.behme@gmail.com \
--cc=grant.likely@secretlab.ca \
--cc=ioan.nicu.ext@nsn.com \
--cc=jluebbe@lasnet.de \
--cc=koen@dominion.thruhere.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=matt.porter@linaro.org \
--cc=mbohan@codeaurora.org \
--cc=monstr@monstr.eu \
--cc=mranostay@gmail.com \
--cc=ms@mycable.de \
--cc=panto@antoniou-consulting.com \
--cc=robherring2@gmail.com \
--cc=s.hauer@pengutronix.de \
--cc=swarren@wwwdotorg.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